]> Cypherpunks.ru repositories - gostls13.git/commit
syscall: avoid writing to p when Pipe(p) fails
authorRuss Cox <rsc@golang.org>
Wed, 8 Dec 2021 23:06:41 +0000 (18:06 -0500)
committerFilippo Valsorda <filippo@golang.org>
Thu, 9 Dec 2021 13:36:38 +0000 (13:36 +0000)
commit474ebb917cb802bf1d08434a265515d50c174082
treefa2d7ffea086b1256d2eeaf686b00afb937162e2
parenta76511f3a40ea69ee4f5cd86e735e1c8a84f0aa2
syscall: avoid writing to p when Pipe(p) fails

Generally speaking Go functions make no guarantees
about what has happened to result parameters on error,
and Pipe is no exception: callers should avoid looking at
p if Pipe returns an error.

However, we had a bug in which ForkExec was using the
content of p after a failed Pipe, and others may too.
As a robustness fix, make Pipe avoid writing to p on failure.

Updates #50057

Change-Id: Ie8955025dbd20702fabadc9bbe1d1a5ac0f36305
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1291271
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/370577
Run-TryBot: Filippo Valsorda <filippo@golang.org>
Trust: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alex Rakoczy <alex@golang.org>
src/syscall/syscall_aix.go
src/syscall/syscall_darwin.go
src/syscall/syscall_dragonfly.go
src/syscall/syscall_freebsd.go
src/syscall/syscall_linux.go
src/syscall/syscall_netbsd.go
src/syscall/syscall_openbsd.go
src/syscall/syscall_plan9.go
src/syscall/syscall_solaris.go