From e76c773561ff68ad0c2884b86fce12b6733c96f6 Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Tue, 22 Dec 2020 00:00:00 -0600 Subject: [PATCH] library: fix a potential error relating to 'exe' logic After 'errno' management was standardized, a couple of fields were added to the api. Only 1 (PIDS_EXE) involved dynamic memory and, unfortunately, it did not conform to that expected normalized ENOMEM convention. Reference(s): . Jun 2018, added 'exe' to library commit ad4269f1189d5a7d68765e291bcfa981b6731c25 . Nov 2017, standardized 'errno' management commit 06be33b43e5ff3f2658e77ef79441ac2e970cfd7 Signed-off-by: Jim Warner --- proc/readproc.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/proc/readproc.c b/proc/readproc.c index 5d648337..32591316 100644 --- a/proc/readproc.c +++ b/proc/readproc.c @@ -1118,8 +1118,10 @@ static proc_t* simple_readproc(PROCTAB *restrict const PT, proc_t *restrict cons if (flags & PROC_FILL_LUID) // value the login user id p->luid = login_uid(path); - if (flags & PROC_FILL_EXE) - p->exe = readlink_exe(path); + if (flags & PROC_FILL_EXE) { + if (!(p->exe = readlink_exe(path))) + rc += 1; + } if (rc == 0) return p; errno = ENOMEM; @@ -1211,8 +1213,10 @@ static proc_t* simple_readtask(PROCTAB *restrict const PT, proc_t *restrict cons if (flags & PROC_FILLSYSTEMD) // get sd-login.h stuff rc += sd2proc(t); - if (flags & PROC_FILL_EXE) - t->exe = readlink_exe(path); + if (flags & PROC_FILL_EXE) { + if (!(t->exe = readlink_exe(path))) + rc += 1; + } #ifdef FALSE_THREADS } #endif