=== modified file 'plugin-runner.c' --- plugin-runner.c 2009-02-09 19:26:19 +0000 +++ plugin-runner.c 2009-02-12 18:56:52 +0000 @@ -65,7 +65,7 @@ SIG_UNBLOCK, kill(), sig_atomic_t */ #include /* errno, EBADF */ -#include /* intmax_t, SCNdMAX, PRIdMAX, */ +#include /* intmax_t, PRIdMAX, strtoimax() */ #define BUFFER_SIZE 256 @@ -313,7 +313,7 @@ struct dirent *dirst; struct stat st; fd_set rfds_all; - int ret, numchars, maxfd = 0; + int ret, maxfd = 0; ssize_t sret; intmax_t tmpmax; uid_t uid = 65534; @@ -380,6 +380,7 @@ error_t parse_opt(int key, char *arg, __attribute__((unused)) struct argp_state *state){ + char *tmp; switch(key){ case 'g': /* --global-options */ if(arg != NULL){ @@ -462,9 +463,10 @@ /* This is already done by parse_opt_config_file() */ break; case 130: /* --userid */ - ret = sscanf(arg, "%" SCNdMAX "%n", &tmpmax, &numchars); - if(ret < 1 or tmpmax != (uid_t)tmpmax - or arg[numchars] != '\0'){ + errno = 0; + tmpmax = strtoimax(arg, &tmp, 10); + if(errno != 0 or tmp == arg or *tmp != '\0' + or tmpmax != (uid_t)tmpmax){ fprintf(stderr, "Bad user ID number: \"%s\", using %" PRIdMAX "\n", arg, (intmax_t)uid); } else { @@ -472,9 +474,10 @@ } break; case 131: /* --groupid */ - ret = sscanf(arg, "%" SCNdMAX "%n", &tmpmax, &numchars); - if(ret < 1 or tmpmax != (gid_t)tmpmax - or arg[numchars] != '\0'){ + errno = 0; + tmpmax = strtoimax(arg, &tmp, 10); + if(errno != 0 or tmp == arg or *tmp != '\0' + or tmpmax != (gid_t)tmpmax){ fprintf(stderr, "Bad group ID number: \"%s\", using %" PRIdMAX "\n", arg, (intmax_t)gid); } else { === modified file 'plugins.d/mandos-client.c' --- plugins.d/mandos-client.c 2009-02-09 19:33:46 +0000 +++ plugins.d/mandos-client.c 2009-02-12 18:56:52 +0000 @@ -36,12 +36,11 @@ #define _GNU_SOURCE /* TEMP_FAILURE_RETRY(), asprintf() */ #include /* fprintf(), stderr, fwrite(), - stdout, ferror(), sscanf(), - remove() */ + stdout, ferror(), remove() */ #include /* uint16_t, uint32_t */ #include /* NULL, size_t, ssize_t */ #include /* free(), EXIT_SUCCESS, EXIT_FAILURE, - srand() */ + srand(), strtof() */ #include /* bool, false, true */ #include /* memset(), strcmp(), strlen(), strerror(), asprintf(), strcpy() */ @@ -56,7 +55,8 @@ #include /* open() */ #include /* opendir(), struct dirent, readdir() */ -#include /* PRIu16, intmax_t, SCNdMAX */ +#include /* PRIu16, PRIdMAX, intmax_t, + strtoimax() */ #include /* assert() */ #include /* perror(), errno */ #include /* nanosleep(), time() */ @@ -894,7 +894,7 @@ int error; int ret; intmax_t tmpmax; - int numchars; + char *tmp; int exitcode = EXIT_SUCCESS; const char *interface = "eth0"; struct ifreq network; @@ -914,8 +914,8 @@ ":!CTYPE-X.509:+CTYPE-OPENPGP" }; bool gnutls_initialized = false; bool gpgme_initialized = false; - double delay = 2.5; - + float delay = 2.5f; + struct sigaction old_sigterm_action; struct sigaction sigterm_action = { .sa_handler = handle_sigterm }; @@ -975,9 +975,10 @@ pubkey = arg; break; case 129: /* --dh-bits */ - ret = sscanf(arg, "%" SCNdMAX "%n", &tmpmax, &numchars); - if(ret < 1 or tmpmax != (typeof(mc.dh_bits))tmpmax - or arg[numchars] != '\0'){ + errno = 0; + tmpmax = strtoimax(arg, &tmp, 10); + if(errno != 0 or tmp == arg or *tmp != '\0' + or tmpmax != (typeof(mc.dh_bits))tmpmax){ fprintf(stderr, "Bad number of DH bits\n"); exit(EXIT_FAILURE); } @@ -987,8 +988,9 @@ mc.priority = arg; break; case 131: /* --delay */ - ret = sscanf(arg, "%lf%n", &delay, &numchars); - if(ret < 1 or arg[numchars] != '\0'){ + errno = 0; + delay = strtof(arg, &tmp); + if(errno != 0 or tmp == arg or *tmp != '\0'){ fprintf(stderr, "Bad delay\n"); exit(EXIT_FAILURE); } @@ -1200,9 +1202,10 @@ goto end; } uint16_t port; - ret = sscanf(address+1, "%" SCNdMAX "%n", &tmpmax, &numchars); - if(ret < 1 or tmpmax != (uint16_t)tmpmax - or address[numchars+1] != '\0'){ + errno = 0; + tmpmax = strtoimax(address+1, &tmp, 10); + if(errno != 0 or tmp == address+1 or *tmp != '\0' + or tmpmax != (uint16_t)tmpmax){ fprintf(stderr, "Bad port number\n"); exitcode = EXIT_FAILURE; goto end; === modified file 'plugins.d/splashy.c' --- plugins.d/splashy.c 2009-01-14 14:20:17 +0000 +++ plugins.d/splashy.c 2009-02-12 18:56:52 +0000 @@ -30,13 +30,13 @@ SIG_IGN, kill(), SIGKILL */ #include /* NULL */ #include /* getenv() */ -#include /* asprintf(), perror(), sscanf() */ +#include /* asprintf(), perror() */ #include /* EXIT_FAILURE, free(), EXIT_SUCCESS */ #include /* pid_t, DIR, struct dirent, ssize_t */ #include /* opendir(), readdir(), closedir() */ -#include /* intmax_t, SCNdMAX */ +#include /* intmax_t, strtoimax() */ #include /* struct stat, lstat(), S_ISLNK */ #include /* not, or, and */ #include /* readlink(), fork(), execl(), @@ -101,11 +101,11 @@ pid_t pid; { intmax_t tmpmax; - int numchars; - ret = sscanf(proc_ent->d_name, "%" SCNdMAX "%n", &tmpmax, - &numchars); - if(ret < 1 or tmpmax != (pid_t)tmpmax - or proc_ent->d_name[numchars] != '\0'){ + char *tmp; + errno = 0; + tmpmax = strtoimax(proc_ent->d_name, &tmp, 10); + if(errno != 0 or tmp == proc_ent->d_name or *tmp != '\0' + or tmpmax != (pid_t)tmpmax){ /* Not a process */ continue; } === modified file 'plugins.d/usplash.c' --- plugins.d/usplash.c 2009-01-14 14:20:17 +0000 +++ plugins.d/usplash.c 2009-02-12 18:56:52 +0000 @@ -36,7 +36,7 @@ dirent */ #include /* NULL */ #include /* strlen(), memcmp() */ -#include /* asprintf(), perror(), sscanf() */ +#include /* asprintf(), perror() */ #include /* close(), write(), readlink(), read(), STDOUT_FILENO, sleep(), fork(), setuid(), geteuid(), @@ -46,7 +46,7 @@ EXIT_SUCCESS, malloc(), _exit() */ #include /* getenv() */ #include /* opendir(), readdir(), closedir() */ -#include /* intmax_t, SCNdMAX */ +#include /* intmax_t, strtoimax() */ #include /* struct stat, lstat(), S_ISLNK */ sig_atomic_t interrupted_by_signal = 0; @@ -173,11 +173,11 @@ pid_t pid; { intmax_t tmpmax; - int numchars; - ret = sscanf(proc_ent->d_name, "%" SCNdMAX "%n", &tmpmax, - &numchars); - if(ret < 1 or tmpmax != (pid_t)tmpmax - or proc_ent->d_name[numchars] != '\0'){ + char *tmp; + errno = 0; + tmpmax = strtoimax(proc_ent->d_name, &tmp, 10); + if(errno != 0 or tmp == proc_ent->d_name or *tmp != '\0' + or tmpmax != (pid_t)tmpmax){ /* Not a process */ continue; }