Module Name: src
Committed By: martin
Date: Wed May 16 09:41:11 UTC 2012
Modified Files:
src/sys/kern: sys_pipe.c
Log Message:
Make sure we can deliver two file descriptors for pipe2() before we set
up anything special (like close on exec).
Fixes PR kern/46457.
To generate a diff of this commit:
cvs rdiff -u -r1.135 -r1.136 src/sys/kern/sys_pipe.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/sys_pipe.c
diff -u src/sys/kern/sys_pipe.c:1.135 src/sys/kern/sys_pipe.c:1.136
--- src/sys/kern/sys_pipe.c:1.135 Wed Jan 25 00:28:36 2012
+++ src/sys/kern/sys_pipe.c Wed May 16 09:41:11 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: sys_pipe.c,v 1.135 2012/01/25 00:28:36 christos Exp $ */
+/* $NetBSD: sys_pipe.c,v 1.136 2012/05/16 09:41:11 martin 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.135 2012/01/25 00:28:36 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_pipe.c,v 1.136 2012/05/16 09:41:11 martin Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -267,21 +267,23 @@ pipe1(struct lwp *l, register_t *retval,
if (error)
goto free2;
retval[0] = fd;
- rf->f_flag = FREAD | flags;
- rf->f_type = DTYPE_PIPE;
- rf->f_data = (void *)rpipe;
- rf->f_ops = &pipeops;
- fd_set_exclose(l, fd, (flags & O_CLOEXEC) != 0);
error = fd_allocfile(&wf, &fd);
if (error)
goto free3;
retval[1] = fd;
+
+ rf->f_flag = FREAD | flags;
+ rf->f_type = DTYPE_PIPE;
+ rf->f_data = (void *)rpipe;
+ rf->f_ops = &pipeops;
+ fd_set_exclose(l, (int)retval[0], (flags & O_CLOEXEC) != 0);
+
wf->f_flag = FWRITE | flags;
wf->f_type = DTYPE_PIPE;
wf->f_data = (void *)wpipe;
wf->f_ops = &pipeops;
- fd_set_exclose(l, fd, (flags & O_CLOEXEC) != 0);
+ fd_set_exclose(l, (int)retval[1], (flags & O_CLOEXEC) != 0);
rpipe->pipe_peer = wpipe;
wpipe->pipe_peer = rpipe;