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



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