Skip to content

Commit

Permalink
keyring: cast FS_IOC_REMOVE_ENCRYPTION_KEY to uintptr (#221)
Browse files Browse the repository at this point in the history
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.]
  • Loading branch information
fstanis authored and ebiggers committed May 9, 2020
1 parent fe86093 commit c576433
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions keyring/fs_keyring.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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",
Expand Down

0 comments on commit c576433

Please sign in to comment.