NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

re: kern/56673: don't allow execve with NULL argv



The following reply was made to PR kern/56673; it has been noted by GNATS.

From: matthew green <mrg%eterna.com.au@localhost>
To: gnats-bugs%netbsd.org@localhost, martin%netbsd.org@localhost
Cc: kern-bug-people%netbsd.org@localhost, gnats-admin%netbsd.org@localhost,
    netbsd-bugs%netbsd.org@localhost
Subject: re: kern/56673: don't allow execve with NULL argv
Date: Sun, 30 Jan 2022 16:57:24 +1100

 this seems to work for me.  martin, ok to commit?
 
 
 .mrg.
 
 
 don't allow exec or spawn with an argument vector of just NULL.
 we already rejected argv == NULL itself, but this was allowed:
    char *argv[1] = { 0 };
 
 
 Index: kern_exec.c
 ===================================================================
 RCS file: /cvsroot/src/sys/kern/kern_exec.c,v
 retrieving revision 1.514
 diff -p -u -r1.514 kern_exec.c
 --- kern_exec.c	26 Nov 2021 08:06:12 -0000	1.514
 +++ kern_exec.c	30 Jan 2022 03:24:42 -0000
 @@ -1666,6 +1666,10 @@ copyinargs(struct execve_data * restrict
  		return error;
  	}
  	data->ed_argc += i;
 +	if (data->ed_argc == 0) {
 +		DPRINTF(("%s: zero args\n", __func__));
 +		return EINVAL;
 +	}
  
  	/*
  	 * Read and count environment strings from user.
 


Home | Main Index | Thread Index | Old Index