Skip to content

Commit

Permalink
forbid execve() with argc == 0. prompted by a millert email.
Browse files Browse the repository at this point in the history
ok deraadt miod
  • Loading branch information
tedu committed Feb 7, 2015
1 parent e4b1fd5 commit 7421256
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion sys/kern/kern_exec.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $OpenBSD: kern_exec.c,v 1.157 2015/01/26 22:51:37 kettenis Exp $ */
/* $OpenBSD: kern_exec.c,v 1.158 2015/02/07 08:47:49 tedu Exp $ */
/* $NetBSD: kern_exec.c,v 1.75 1996/02/09 18:59:28 christos Exp $ */

/*-
Expand Down Expand Up @@ -373,6 +373,12 @@ sys_execve(struct proc *p, void *v, register_t *retval)
argc++;
}

/* must have at least one argument */
if (argc == 0) {
error = EINVAL;
goto bad;
}

envc = 0;
/* environment does not need to be there */
if ((cpp = SCARG(uap, envp)) != NULL ) {
Expand Down

0 comments on commit 7421256

Please sign in to comment.