From c5764330ebc69f15b9bf13b94cfef45732864b5a Mon Sep 17 00:00:00 2001 From: Filip Stanis Date: Tue, 5 May 2020 02:48:26 +0100 Subject: [PATCH] keyring: cast FS_IOC_REMOVE_ENCRYPTION_KEY to uintptr (#221) Since v0.2.6, fscrypt only builds for 64-bit systems. E.g. trying to build on Raspbian fails with the following error: $ go get github.com/google/fscrypt/cmd/fscrypt # github.com/google/fscrypt/keyring go/src/github.com/google/fscrypt/keyring/fs_keyring.go:231:6: constant 3225445912 overflows int go/src/github.com/google/fscrypt/keyring/fs_keyring.go:235:7: constant 3225445913 overflows int Fix it by making the 'ioc' variable have type uintptr. [EB - removed the later cast to uintptr that became unnecessary, and added explanation to commit message.] --- keyring/fs_keyring.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/keyring/fs_keyring.go b/keyring/fs_keyring.go index f0016a47..262e0e5b 100644 --- a/keyring/fs_keyring.go +++ b/keyring/fs_keyring.go @@ -228,7 +228,7 @@ func fsRemoveEncryptionKey(descriptor string, mount *filesystem.Mount, return err } - ioc := unix.FS_IOC_REMOVE_ENCRYPTION_KEY + ioc := uintptr(unix.FS_IOC_REMOVE_ENCRYPTION_KEY) iocName := "FS_IOC_REMOVE_ENCRYPTION_KEY" var savedPrivs *savedPrivs if user == nil { @@ -240,7 +240,7 @@ func fsRemoveEncryptionKey(descriptor string, mount *filesystem.Mount, return err } } - _, _, errno := unix.Syscall(unix.SYS_IOCTL, dir.Fd(), uintptr(ioc), uintptr(unsafe.Pointer(&arg))) + _, _, errno := unix.Syscall(unix.SYS_IOCTL, dir.Fd(), ioc, uintptr(unsafe.Pointer(&arg))) restorePrivs(savedPrivs) log.Printf("%s(%q, %s) = %v, removal_status_flags=0x%x",