Module Name:    src
Committed By:   christos
Date:           Fri Jul 15 14:50:20 UTC 2011

Modified Files:
        src/sys/kern: kern_descrip.c sys_pipe.c uipc_syscalls.c

Log Message:
fail with EINVAL if flags not are not O_CLOEXEC|O_NONBLOCK in pipe2(2) and
dup3(2)


To generate a diff of this commit:
cvs rdiff -u -r1.215 -r1.216 src/sys/kern/kern_descrip.c
cvs rdiff -u -r1.131 -r1.132 src/sys/kern/sys_pipe.c
cvs rdiff -u -r1.144 -r1.145 src/sys/kern/uipc_syscalls.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/kern_descrip.c
diff -u src/sys/kern/kern_descrip.c:1.215 src/sys/kern/kern_descrip.c:1.216
--- src/sys/kern/kern_descrip.c:1.215	Sun Jun 26 12:42:41 2011
+++ src/sys/kern/kern_descrip.c	Fri Jul 15 10:50:19 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_descrip.c,v 1.215 2011/06/26 16:42:41 christos Exp $	*/
+/*	$NetBSD: kern_descrip.c,v 1.216 2011/07/15 14:50:19 christos Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_descrip.c,v 1.215 2011/06/26 16:42:41 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_descrip.c,v 1.216 2011/07/15 14:50:19 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -735,6 +735,8 @@
 	fdfile_t *ff;
 	fdtab_t *dt;
 
+	if (flags & ~(O_CLOEXEC|O_NONBLOCK))
+		return EINVAL;
 	/*
 	 * Ensure there are enough slots in the descriptor table,
 	 * and allocate an fdfile_t up front in case we need it.

Index: src/sys/kern/sys_pipe.c
diff -u src/sys/kern/sys_pipe.c:1.131 src/sys/kern/sys_pipe.c:1.132
--- src/sys/kern/sys_pipe.c:1.131	Sun Jun 26 12:42:42 2011
+++ src/sys/kern/sys_pipe.c	Fri Jul 15 10:50:19 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: sys_pipe.c,v 1.131 2011/06/26 16:42:42 christos Exp $	*/
+/*	$NetBSD: sys_pipe.c,v 1.132 2011/07/15 14:50:19 christos Exp $	*/
 
 /*-
  * Copyright (c) 2003, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_pipe.c,v 1.131 2011/06/26 16:42:42 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_pipe.c,v 1.132 2011/07/15 14:50:19 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -251,6 +251,8 @@
 	int fd, error;
 	proc_t *p;
 
+	if (flags & ~(O_CLOEXEC|O_NONBLOCK))
+		return EINVAL;
 	p = curproc;
 	rpipe = wpipe = NULL;
 	if (pipe_create(&rpipe, pipe_rd_cache) ||

Index: src/sys/kern/uipc_syscalls.c
diff -u src/sys/kern/uipc_syscalls.c:1.144 src/sys/kern/uipc_syscalls.c:1.145
--- src/sys/kern/uipc_syscalls.c:1.144	Sun Jun 26 12:42:42 2011
+++ src/sys/kern/uipc_syscalls.c	Fri Jul 15 10:50:19 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: uipc_syscalls.c,v 1.144 2011/06/26 16:42:42 christos Exp $	*/
+/*	$NetBSD: uipc_syscalls.c,v 1.145 2011/07/15 14:50:19 christos Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls.c,v 1.144 2011/06/26 16:42:42 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls.c,v 1.145 2011/07/15 14:50:19 christos Exp $");
 
 #include "opt_pipe.h"
 
@@ -1021,6 +1021,8 @@
 	int		fd, error;
 	proc_t		*p;
 
+	if (flags & ~(O_CLOEXEC|O_NONBLOCK))
+		return EINVAL;
 	p = curproc;
 	if ((error = socreate(AF_LOCAL, &rso, SOCK_STREAM, 0, l, NULL)) != 0)
 		return (error);

Reply via email to