]> Cypherpunks repositories - gostls13.git/commitdiff
syscall: fix shadowing bugs in forkAndExecInChild
authorBryan C. Mills <bcmills@google.com>
Fri, 9 Dec 2022 17:25:22 +0000 (12:25 -0500)
committerBryan Mills <bcmills@google.com>
Mon, 12 Dec 2022 14:38:22 +0000 (14:38 +0000)
Fixes #57208.
Updates #23152.

Change-Id: Icc9a74aeb26f1b6f151162c5d6bf1b4d7cd54d0a
Reviewed-on: https://go-review.googlesource.com/c/go/+/456515
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

src/syscall/exec_freebsd.go
src/syscall/exec_linux.go

index b85bcd93a82bca9b8841b9cce2716c6548f0a5ac..af5a4158f04fec01ed1a9408b7ee2e89ed0869ee 100644 (file)
@@ -205,7 +205,7 @@ func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr
                r1, _, _ = RawSyscall(SYS_GETPPID, 0, 0, 0)
                if r1 != ppid {
                        pid, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0)
-                       _, _, err1 := RawSyscall(SYS_KILL, pid, uintptr(sys.Pdeathsig), 0)
+                       _, _, err1 = RawSyscall(SYS_KILL, pid, uintptr(sys.Pdeathsig), 0)
                        if err1 != 0 {
                                goto childerror
                        }
index b61b51dff1d42bc7b8de72b1e90114e07b89633e..7e0c3d250bcb984e481f828cda1db52efec15a4d 100644 (file)
@@ -470,7 +470,7 @@ func forkAndExecInChild1(argv0 *byte, argv, envv []*byte, chroot, dir *byte, att
                // so it is safe to always use _LINUX_CAPABILITY_VERSION_3.
                caps.hdr.version = _LINUX_CAPABILITY_VERSION_3
 
-               if _, _, err1 := RawSyscall(SYS_CAPGET, uintptr(unsafe.Pointer(&caps.hdr)), uintptr(unsafe.Pointer(&caps.data[0])), 0); err1 != 0 {
+               if _, _, err1 = RawSyscall(SYS_CAPGET, uintptr(unsafe.Pointer(&caps.hdr)), uintptr(unsafe.Pointer(&caps.data[0])), 0); err1 != 0 {
                        goto childerror
                }
 
@@ -481,7 +481,7 @@ func forkAndExecInChild1(argv0 *byte, argv, envv []*byte, chroot, dir *byte, att
                        caps.data[capToIndex(c)].inheritable |= capToMask(c)
                }
 
-               if _, _, err1 := RawSyscall(SYS_CAPSET, uintptr(unsafe.Pointer(&caps.hdr)), uintptr(unsafe.Pointer(&caps.data[0])), 0); err1 != 0 {
+               if _, _, err1 = RawSyscall(SYS_CAPSET, uintptr(unsafe.Pointer(&caps.hdr)), uintptr(unsafe.Pointer(&caps.data[0])), 0); err1 != 0 {
                        goto childerror
                }
 
@@ -514,7 +514,7 @@ func forkAndExecInChild1(argv0 *byte, argv, envv []*byte, chroot, dir *byte, att
                r1, _ = rawSyscallNoError(SYS_GETPPID, 0, 0, 0)
                if r1 != ppid {
                        pid, _ := rawSyscallNoError(SYS_GETPID, 0, 0, 0)
-                       _, _, err1 := RawSyscall(SYS_KILL, pid, uintptr(sys.Pdeathsig), 0)
+                       _, _, err1 = RawSyscall(SYS_KILL, pid, uintptr(sys.Pdeathsig), 0)
                        if err1 != 0 {
                                goto childerror
                        }