Check malloc retval and mark ptr arguments non-null

pull/13/head
Daniel Roethlisberger 10 years ago
parent 3579fb6891
commit 2cc353f274

@ -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;

@ -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;

Loading…
Cancel
Save