Skip to content

Commit cb07765

Browse files
millerresearchgopherbot
authored andcommitted
syscall: fix closing of reordered FDs in plan9 ForkExec
After dup'ing file descriptors in syscall.ProcAttr.Files to pass to the exec'ed process, the logic for closing the old descriptors was incorrect and could close the new descriptor instead. Fixes #57180 Change-Id: I7725f21a465ffba57050fe4e36f3d36ba181cfb2 Reviewed-on: https://go-review.googlesource.com/c/go/+/457115 Run-TryBot: David du Colombier <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Auto-Submit: Bryan Mills <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Reviewed-by: David du Colombier <[email protected]> Reviewed-by: Bryan Mills <[email protected]>
1 parent 5ba98b9 commit cb07765

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/syscall/exec_plan9.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ dirloop:
276276

277277
// Pass 3: close fd[i] if it was moved in the previous pass.
278278
for i = 0; i < len(fd); i++ {
279-
if fd[i] >= 0 && fd[i] != int(i) {
279+
if fd[i] >= len(fd) {
280280
RawSyscall(SYS_CLOSE, uintptr(fd[i]), 0, 0)
281281
}
282282
}

0 commit comments

Comments
 (0)