diff --git a/sys.c b/sys.c index 3d54f68..502e32f 100644 --- a/sys.c +++ b/sys.c @@ -217,6 +217,9 @@ sys_proc_info(pid_t pid, char **path, uid_t *uid, gid_t *gid) { /* fetch process path */ *path = malloc(PROC_PIDPATHINFO_MAXSIZE); + if (!*path) { + return -1; + } int path_len = proc_pidpath(pid, *path, PROC_PIDPATHINFO_MAXSIZE); if (path_len == -1) { free(*path); @@ -238,7 +241,7 @@ char * sys_user_str(uid_t uid) { int bufsize; - if ((bufsize = sysconf(_SC_GETPW_R_SIZE_MAX)) == -1) { + if ((bufsize = sysconf(_SC_GETPW_R_SIZE_MAX)) == -1) { log_err_printf("failed to get password bufsize: %s\n", strerror(errno)); return NULL; diff --git a/sys.h b/sys.h index 537ab1b..2412c48 100644 --- a/sys.h +++ b/sys.h @@ -41,7 +41,7 @@ int sys_pidf_open(const char *) NONNULL(1) WUNRES; int sys_pidf_write(int) WUNRES; void sys_pidf_close(int, const char *) NONNULL(2); -int sys_proc_info(pid_t, char **, uid_t *, gid_t *) WUNRES; +int sys_proc_info(pid_t, char **, uid_t *, gid_t *) WUNRES NONNULL(2,3,4); char * sys_user_str(uid_t) WUNRES MALLOC; char * sys_group_str(gid_t) WUNRES MALLOC;