mirror of
https://github.com/golang/go
synced 2024-09-30 03:24:39 -06:00
os/user: on AIX getpwuid_r seems to return -1 on overflow
The getpwuid_r function is expected to return ERANGE on overflow. Accept -1 on AIX as we see that in practice. This problem was uncovered by, but not caused by, CL 455815, which introduced a test that forced a buffer overflow. Change-Id: I3ae94faf1257d2c73299b1478e49769bb807fc4d Reviewed-on: https://go-review.googlesource.com/c/go/+/456075 Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
parent
9431237d77
commit
b9747e0e6b
@ -8,6 +8,7 @@ package user
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"syscall"
|
||||
@ -170,6 +171,9 @@ func retryWithBuffer(startSize bufferKind, f func([]byte) syscall.Errno) error {
|
||||
errno := f(buf)
|
||||
if errno == 0 {
|
||||
return nil
|
||||
} else if runtime.GOOS == "aix" && errno+1 == 0 {
|
||||
// On AIX getpwuid_r appears to return -1,
|
||||
// not ERANGE, on buffer overflow.
|
||||
} else if errno != syscall.ERANGE {
|
||||
return errno
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user