]> Cypherpunks repositories - gostls13.git/commit
syscall: fix accidental close of exec status pipe in StartProcess
authorRichard Miller <miller.research@gmail.com>
Sat, 26 Mar 2016 19:35:21 +0000 (19:35 +0000)
committerBrad Fitzpatrick <bradfitz@golang.org>
Tue, 29 Mar 2016 00:03:14 +0000 (00:03 +0000)
commit1f0bebcc7260480550ad114048a9428cea68e4f1
treebef4da1a688e02cfde094d423cd451c10cd42751
parent272df158ac431cc253b87a713735df70155ed456
syscall: fix accidental close of exec status pipe in StartProcess

In syscall.forkAndExecInChild, blocks of code labelled Pass 1
and Pass 2 permute the file descriptors (if necessary) which are
passed to the child process.  If Pass 1 begins with fds = {0,2,1},
nextfd = 4 and pipe = 4, then the statement labelled "don't stomp
on pipe" is too late -- the pipe (which will be needed to pass
exec status back to the parent) will have been closed by the
preceding DUP call.

Moving the "don't stomp" test earlier ensures that the pipe is
protected.

Fixes #14979

Change-Id: I890c311527f6aa255be48b3277c1e84e2049ee22
Reviewed-on: https://go-review.googlesource.com/21184
Run-TryBot: David du Colombier <0intro@gmail.com>
Reviewed-by: David du Colombier <0intro@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/syscall/exec_bsd.go
src/syscall/exec_linux.go
src/syscall/exec_plan9.go
src/syscall/exec_solaris.go
src/syscall/syscall_test.go