Skip to content

Commit d8f57a1

Browse files
authored
Merge pull request #61 from danieljoos/linux32
Workaround for Linux 32-bit build
2 parents 4bc0bc2 + cdde659 commit d8f57a1

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

secretservice/secretservice_linux.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,11 @@ func (h Secretservice) List() (map[string]string, error) {
105105
if listLen == 0 {
106106
return resp, nil
107107
}
108-
pathTmp := (*[1 << 30]*C.char)(unsafe.Pointer(pathsC))[:listLen:listLen]
109-
acctTmp := (*[1 << 30]*C.char)(unsafe.Pointer(acctsC))[:listLen:listLen]
108+
// The maximum capacity of the following two slices is limited to (2^29)-1 to remain compatible
109+
// with 32-bit platforms. The size of a `*C.char` (a pointer) is 4 Byte on a 32-bit system
110+
// and (2^29)*4 == math.MaxInt32 + 1. -- See issue golang/go#13656
111+
pathTmp := (*[(1 << 29) - 1]*C.char)(unsafe.Pointer(pathsC))[:listLen:listLen]
112+
acctTmp := (*[(1 << 29) - 1]*C.char)(unsafe.Pointer(acctsC))[:listLen:listLen]
110113
for i := 0; i < listLen; i++ {
111114
resp[C.GoString(pathTmp[i])] = C.GoString(acctTmp[i])
112115
}

0 commit comments

Comments
 (0)