diff options
author | 2003-06-17 00:51:29 +0000 | |
---|---|---|
committer | 2003-06-17 00:51:29 +0000 | |
commit | 3b12c940d3a0791b996d0c44a73b600ccd7ad624 (patch) | |
tree | a76ef9bc0f1a11b64ce761c5d3a181ee6c926033 | |
parent | Give this header file, which was split off by d@, the same (BSD) license as (diff) | |
download | wireguard-openbsd-3b12c940d3a0791b996d0c44a73b600ccd7ad624.tar.xz wireguard-openbsd-3b12c940d3a0791b996d0c44a73b600ccd7ad624.zip |
properly typecast to uid_t the return value of proc_owner() and report
ESRCH instead of EACCES if it returns -1
ok millert@
-rw-r--r-- | usr.bin/top/commands.c | 9 | ||||
-rw-r--r-- | usr.bin/top/machine.c | 6 |
2 files changed, 9 insertions, 6 deletions
diff --git a/usr.bin/top/commands.c b/usr.bin/top/commands.c index e88892c6359..77d51e8e04d 100644 --- a/usr.bin/top/commands.c +++ b/usr.bin/top/commands.c @@ -1,4 +1,4 @@ -/* $OpenBSD: commands.c,v 1.10 2003/06/15 16:24:44 millert Exp $ */ +/* $OpenBSD: commands.c,v 1.11 2003/06/17 00:51:29 jfb Exp $ */ /* * Top users/processes display for Unix @@ -319,7 +319,7 @@ kill_procs(char *str) { int signum = SIGTERM, procnum; struct sigdesc *sigp; - uid_t uid; + uid_t uid, puid; char *nptr; /* reset error array */ @@ -363,7 +363,10 @@ kill_procs(char *str) ERROR(str, 0); } else { /* check process owner if we're not root */ - if (uid && (uid != proc_owner(procnum))) { + puid = proc_owner(procnum); + if (puid == (uid_t)(-1)) { + ERROR(str, ESRCH); + } else if (uid && (uid != puid)) { ERROR(str, EACCES); } else if (kill(procnum, signum) == -1) { ERROR(str, errno); diff --git a/usr.bin/top/machine.c b/usr.bin/top/machine.c index 46b4673b049..ad1ceceb849 100644 --- a/usr.bin/top/machine.c +++ b/usr.bin/top/machine.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machine.c,v 1.33 2003/06/15 16:24:44 millert Exp $ */ +/* $OpenBSD: machine.c,v 1.34 2003/06/17 00:51:29 jfb Exp $ */ /*- * Copyright (c) 1994 Thorsten Lockert <tholo@sigmasoft.com> @@ -621,9 +621,9 @@ proc_owner(pid_t pid) while (--cnt >= 0) { pp = *prefp++; if (PP(pp, p_pid) == pid) - return ((int) EP(pp, e_pcred.p_ruid)); + return ((uid_t) EP(pp, e_pcred.p_ruid)); } - return (-1); + return (uid_t)(-1); } /* |