From: Todd C. Miller Date: Sun, 17 Apr 2005 05:18:24 +0000 (+0000) Subject: Don't do pointer arithmetic on void * X-Git-Tag: SUDO_1_7_0~650 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=95c47e7f3bc018f66b0ca30597b84614a6b159b8;p=sudo Don't do pointer arithmetic on void * Use int, not size_t/ssize_t for systrace lengths (since it uses int) --- diff --git a/mon_systrace.c b/mon_systrace.c index b103c17c1..1c16eee8f 100644 --- a/mon_systrace.c +++ b/mon_systrace.c @@ -200,8 +200,7 @@ systrace_attach(pid) /* handle systrace events until the child finishes */ for (;;) { - nread = read(fd, &msg, sizeof(msg)); - if (nread != sizeof(msg)) { + if ((nread = read(fd, &msg, sizeof(msg))) != sizeof(msg)) { if (dodetach) { detachall(fd); _exit(0); @@ -453,9 +452,9 @@ static int systrace_read(fd, pid, addr, buf, bufsiz) int fd; pid_t pid; - void *addr; + char *addr; void *buf; - size_t bufsiz; + int bufsiz; { struct systrace_io io; @@ -474,15 +473,15 @@ systrace_read(fd, pid, addr, buf, bufsiz) * handle a strio_len > the actual kernel buffer. It might be nice * to pass a starting chunksize though. */ -static ssize_t +static int read_string(fd, pid, addr, buf, bufsiz) int fd; pid_t pid; - void *addr; + char *addr; char *buf; - size_t bufsiz; + int bufsiz; { - size_t chunksiz = 32; + int chunksiz = 32; char *cp = buf, *ep; while (bufsiz >= chunksiz) { @@ -537,9 +536,9 @@ static int systrace_write(fd, pid, addr, buf, len) int fd; pid_t pid; - void *addr; + char *addr; void *buf; - size_t len; + int len; { struct systrace_io io; @@ -563,10 +562,9 @@ update_env(fd, pid, seqnr, askp) struct str_msg_ask *askp; { struct systrace_replace repl; - ssize_t len; char *envbuf[ARG_MAX / sizeof(char *)], **envp, **envep; char buf[ARG_MAX], *ap, *cp, *off, *envptrs[4], *offsets[4], *replace[4]; - int n; + int len, n; /* * Iterate through the environment, copying the data pointers and @@ -769,7 +767,7 @@ decode_args(fd, pid, askp) pid_t pid; struct str_msg_ask *askp; { - ssize_t len; + int len; char *off, *ap, *cp, *ep; static char pbuf[PATH_MAX], abuf[ARG_MAX]; diff --git a/mon_systrace.h b/mon_systrace.h index a28f7a301..d49471ca3 100644 --- a/mon_systrace.h +++ b/mon_systrace.h @@ -30,13 +30,13 @@ static int decode_args __P((int, pid_t, struct str_msg_ask *)); static int set_policy __P((int, struct childinfo *)); static int switch_emulation __P((int, struct str_message *)); static int systrace_open __P((void)); -static int systrace_read __P((int, pid_t, void *, void *, size_t)); +static int systrace_read __P((int, pid_t, char *, void *, int)); #ifdef STRIOCINJECT -static int systrace_write __P((int, pid_t, void *, void *, size_t)); +static int systrace_write __P((int, pid_t, char *, void *, int)); static int update_env __P((int, pid_t, u_int16_t, struct str_msg_ask *)); #endif static schandler_t find_handler __P((pid_t, int)); -static ssize_t read_string __P((int, pid_t, void *, char *, size_t)); +static int read_string __P((int, pid_t, char *, char *, int)); static struct childinfo *find_child __P((pid_t)); static void catchsig __P((int)); static void detachall __P((int));