]> Cypherpunks repositories - gostls13.git/commitdiff
os: enable the close-on-exec flag for openFdAt
authorBaokun Lee <nototon@gmail.com>
Thu, 1 Aug 2019 16:31:57 +0000 (00:31 +0800)
committerIan Lance Taylor <iant@golang.org>
Thu, 1 Aug 2019 20:37:08 +0000 (20:37 +0000)
There's a race here with fork/exec, enable the close-on-exec flag
for the new file descriptor.

Fixes #33405

Change-Id: If95bae97a52b7026a930bb3427e47bae3b0032ac
Reviewed-on: https://go-review.googlesource.com/c/go/+/188537
Run-TryBot: Baokun Lee <nototon@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/os/removeall_at.go

index 3098b93368d3c59f6ac6b0a628de39258bb2594d..bc632f5a751bd118f7090eae12efdb466535b7ba 100644 (file)
@@ -173,7 +173,7 @@ func openFdAt(dirfd int, name string) (*File, error) {
        var r int
        for {
                var e error
-               r, e = unix.Openat(dirfd, name, O_RDONLY, 0)
+               r, e = unix.Openat(dirfd, name, O_RDONLY|syscall.O_CLOEXEC, 0)
                if e == nil {
                        break
                }