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>
import (
"fmt"
+ "runtime"
"strconv"
"strings"
"syscall"
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
}