fix uid/gid > 2^31
This MR revisits a partial fix from 2018. The problem stems from incorrect handling of unsigned 32-bit uid_ts and gid_ts as signed when values are large - i.e. when the high bit is set. In that case, pgrep and pkill fail to identify processes by uid. (They succeed when finding the same processes by username.) The primary fix for this is to impliment the "FIXME" comment in proc/readproc.h, the implementation of which allows the removal of the (int) casts from the partial fix from 2018. The other fixed code in this MR consists of tests in strict_atol() that detects and errors out on overflows. References: Merge !146
This commit is contained in:
@@ -152,12 +152,13 @@ typedef struct proc_t {
|
||||
session, // stat session id
|
||||
nlwp, // stat,status number of threads, or 0 if no clue
|
||||
tgid, // (special) thread group ID, the POSIX PID (see also: tid)
|
||||
tty, // stat full device number of controlling terminal
|
||||
tty; // stat full device number of controlling terminal
|
||||
/* FIXME: int uids & gids should be uid_t or gid_t from pwd.h */
|
||||
euid, egid, // stat(),status effective
|
||||
ruid, rgid, // status real
|
||||
suid, sgid, // status saved
|
||||
fuid, fgid, // status fs (used for file access only)
|
||||
uid_t euid; gid_t egid; // stat(),status effective
|
||||
uid_t ruid; gid_t rgid; // status real
|
||||
uid_t suid; gid_t sgid; // status saved
|
||||
uid_t fuid; gid_t fgid; // status fs (used for file access only)
|
||||
int
|
||||
tpgid, // stat terminal process group id
|
||||
exit_signal, // stat might not be SIGCHLD
|
||||
processor; // stat current (or most recent?) CPU
|
||||
|
Reference in New Issue
Block a user