mirror of
https://github.com/docker/docker-credential-helpers.git
synced 2026-06-13 16:01:28 +05:30
Workaround for Linux 32-bit build
This adds a workaround for the `secretservice` sub-package to build under 32bit Linux. It limits the total number of list entries to (2^29)-1. A short explanation of how this number was calculated has been added in a comment. Signed-off-by: Daniel Joos <daniel@joosweb.de>
This commit is contained in:
@@ -105,8 +105,11 @@ func (h Secretservice) List() (map[string]string, error) {
|
|||||||
if listLen == 0 {
|
if listLen == 0 {
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
pathTmp := (*[1 << 30]*C.char)(unsafe.Pointer(pathsC))[:listLen:listLen]
|
// The maximum capacity of the following two slices is limited to (2^29)-1 to remain compatible
|
||||||
acctTmp := (*[1 << 30]*C.char)(unsafe.Pointer(acctsC))[:listLen:listLen]
|
// with 32-bit platforms. The size of a `*C.char` (a pointer) is 4 Byte on a 32-bit system
|
||||||
|
// and (2^29)*4 == math.MaxInt32 + 1. -- See issue golang/go#13656
|
||||||
|
pathTmp := (*[(1 << 29) - 1]*C.char)(unsafe.Pointer(pathsC))[:listLen:listLen]
|
||||||
|
acctTmp := (*[(1 << 29) - 1]*C.char)(unsafe.Pointer(acctsC))[:listLen:listLen]
|
||||||
for i := 0; i < listLen; i++ {
|
for i := 0; i < listLen; i++ {
|
||||||
resp[C.GoString(pathTmp[i])] = C.GoString(acctTmp[i])
|
resp[C.GoString(pathTmp[i])] = C.GoString(acctTmp[i])
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user