=== modified file 'plugin-runner.c' --- plugin-runner.c 2009-01-13 04:35:19 +0000 +++ plugin-runner.c 2009-01-14 14:20:17 +0000 @@ -64,6 +64,7 @@ sigprocmask(), SIG_BLOCK, SIGCHLD, SIG_UNBLOCK, kill() */ #include /* errno, EBADF */ +#include /* intmax_t, SCNdMAX, PRIdMAX, */ #define BUFFER_SIZE 256 @@ -308,8 +309,9 @@ struct dirent *dirst; struct stat st; fd_set rfds_all; - int ret, maxfd = 0; + int ret, numchars, maxfd = 0; ssize_t sret; + intmax_t tmpmax; uid_t uid = 65534; gid_t gid = 65534; bool debug = false; @@ -463,19 +465,23 @@ /* This is already done by parse_opt_config_file() */ break; case 130: /* --userid */ - /* In the GNU C library, uid_t is always unsigned int */ - ret = sscanf(arg, "%u", &uid); - if(ret != 1){ - fprintf(stderr, "Bad user ID number: \"%s\", using %u\n", arg, - uid); + ret = sscanf(arg, "%" SCNdMAX "%n", &tmpmax, &numchars); + if(ret < 1 or tmpmax != (uid_t)tmpmax + or arg[numchars] != '\0'){ + fprintf(stderr, "Bad user ID number: \"%s\", using %" + PRIdMAX "\n", arg, (intmax_t)uid); + } else { + uid = (uid_t)tmpmax; } break; case 131: /* --groupid */ - /* In the GNU C library, gid_t is always unsigned int */ - ret = sscanf(arg, "%u", &gid); - if(ret != 1){ - fprintf(stderr, "Bad group ID number: \"%s\", using %u\n", - arg, gid); + ret = sscanf(arg, "%" SCNdMAX "%n", &tmpmax, &numchars); + if(ret < 1 or tmpmax != (gid_t)tmpmax + or arg[numchars] != '\0'){ + fprintf(stderr, "Bad group ID number: \"%s\", using %" + PRIdMAX "\n", arg, (intmax_t)gid); + } else { + gid = (gid_t)tmpmax; } break; case 132: /* --debug */ @@ -647,7 +653,7 @@ for(char **a = p->argv; *a != NULL; a++){ fprintf(stderr, "\tArg: %s\n", *a); } - fprintf(stderr, "...and %u environment variables\n", p->envc); + fprintf(stderr, "...and %d environment variables\n", p->envc); for(char **a = p->environ; *a != NULL; a++){ fprintf(stderr, "\t%s\n", *a); } @@ -960,16 +966,16 @@ if(debug){ if(WIFEXITED(proc->status)){ - fprintf(stderr, "Plugin %u exited with status %d\n", - (unsigned int) (proc->pid), + fprintf(stderr, "Plugin %" PRIdMAX " exited with status" + " %d\n", (intmax_t) (proc->pid), WEXITSTATUS(proc->status)); } else if(WIFSIGNALED(proc->status)) { - fprintf(stderr, "Plugin %u killed by signal %d\n", - (unsigned int) (proc->pid), + fprintf(stderr, "Plugin %" PRIdMAX " killed by signal" + " %d\n", (intmax_t) (proc->pid), WTERMSIG(proc->status)); } else if(WCOREDUMP(proc->status)){ - fprintf(stderr, "Plugin %u dumped core\n", - (unsigned int) (proc->pid)); + fprintf(stderr, "Plugin %" PRIdMAX " dumped core\n", + (intmax_t) (proc->pid)); } } === modified file 'plugins.d/mandos-client.c' --- plugins.d/mandos-client.c 2009-01-13 04:45:33 +0000 +++ plugins.d/mandos-client.c 2009-01-14 14:20:17 +0000 @@ -57,7 +57,7 @@ #include /* open() */ #include /* opendir(), struct dirent, readdir() */ -#include /* PRIu16, SCNu16 */ +#include /* PRIu16, intmax_t, SCNdMAX */ #include /* assert() */ #include /* perror(), errno */ #include /* time() */ @@ -754,8 +754,8 @@ avahi_address_snprint(ip, sizeof(ip), address); if(debug){ fprintf(stderr, "Mandos server \"%s\" found on %s (%s, %" - PRIu16 ") on port %d\n", name, host_name, ip, - interface, port); + PRIdMAX ") on port %" PRIu16 "\n", name, host_name, + ip, (intmax_t)interface, port); } int ret = start_mandos_communication(ip, port, interface, mc); if(ret == 0){ @@ -821,6 +821,8 @@ AvahiSServiceBrowser *sb = NULL; int error; int ret; + intmax_t tmpmax; + int numchars; int exitcode = EXIT_SUCCESS; const char *interface = "eth0"; struct ifreq network; @@ -891,11 +893,13 @@ pubkey = arg; break; case 129: /* --dh-bits */ - ret = sscanf(arg, "%u", &mc.dh_bits); - if(ret != 1){ + ret = sscanf(arg, "%" SCNdMAX "%n", &tmpmax, &numchars); + if(ret < 1 or tmpmax != (typeof(mc.dh_bits))tmpmax + or arg[numchars] != '\0'){ fprintf(stderr, "Bad number of DH bits\n"); exit(EXIT_FAILURE); } + mc.dh_bits = (typeof(mc.dh_bits))tmpmax; break; case 130: /* --priority */ mc.priority = arg; @@ -1004,12 +1008,14 @@ goto end; } uint16_t port; - ret = sscanf(address+1, "%" SCNu16, &port); - if(ret != 1){ + ret = sscanf(address+1, "%" SCNdMAX "%n", &tmpmax, &numchars); + if(ret < 1 or tmpmax != (uint16_t)tmpmax + or address[numchars+1] != '\0'){ fprintf(stderr, "Bad port number\n"); exitcode = EXIT_FAILURE; goto end; } + port = (uint16_t)tmpmax; *address = '\0'; address = connect_to; ret = start_mandos_communication(address, port, if_index, &mc); === modified file 'plugins.d/splashy.c' --- plugins.d/splashy.c 2009-01-13 04:29:35 +0000 +++ plugins.d/splashy.c 2009-01-14 14:20:17 +0000 @@ -36,6 +36,7 @@ #include /* pid_t, DIR, struct dirent, ssize_t */ #include /* opendir(), readdir(), closedir() */ +#include /* intmax_t, SCNdMAX */ #include /* struct stat, lstat(), S_ISLNK */ #include /* not, or, and */ #include /* readlink(), fork(), execl(), @@ -98,11 +99,17 @@ proc_ent != NULL; proc_ent = readdir(proc_dir)){ pid_t pid; - /* In the GNU C library, pid_t is always int */ - ret = sscanf(proc_ent->d_name, "%d", &pid); - if(ret != 1){ - /* Not a process */ - continue; + { + 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'){ + /* Not a process */ + continue; + } + pid = (pid_t)tmpmax; } /* Find the executable name by doing readlink() on the /proc//exe link */ === modified file 'plugins.d/usplash.c' --- plugins.d/usplash.c 2009-01-13 04:29:35 +0000 +++ plugins.d/usplash.c 2009-01-14 14:20:17 +0000 @@ -46,6 +46,7 @@ EXIT_SUCCESS, malloc(), _exit() */ #include /* getenv() */ #include /* opendir(), readdir(), closedir() */ +#include /* intmax_t, SCNdMAX */ #include /* struct stat, lstat(), S_ISLNK */ sig_atomic_t interrupted_by_signal = 0; @@ -170,11 +171,17 @@ proc_ent != NULL; proc_ent = readdir(proc_dir)){ pid_t pid; - /* In the GNU C library, pid_t is always int */ - ret = sscanf(proc_ent->d_name, "%d", &pid); - if(ret != 1){ - /* Not a process */ - continue; + { + 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'){ + /* Not a process */ + continue; + } + pid = (pid_t)tmpmax; } /* Find the executable name by doing readlink() on the /proc//exe link */