Skip to content

Commit

Permalink
osutil/chattr.go: avoid possible garbage collection of unsafe pointer (
Browse files Browse the repository at this point in the history
…#15008)

Documentation for `unsafe.Pointer` explicitly mentions that uintptr
cannot be stored in variable before implicit conversion back to
Pointer during system call.

Signed-off-by: Zeyad Gouda <[email protected]>
  • Loading branch information
ZeyadYasser authored Feb 4, 2025
1 parent 7fe9be2 commit 4fd3221
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions osutil/chattr.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ const (
)

func ioctl(f *os.File, request uintptr, attrp *int32) error {
argp := uintptr(unsafe.Pointer(attrp))
_, _, errno := syscall.Syscall(syscall.SYS_IOCTL, f.Fd(), request, argp)
_, _, errno := syscall.Syscall(syscall.SYS_IOCTL, f.Fd(), request, uintptr(unsafe.Pointer(attrp)))
if errno != 0 {
return os.NewSyscallError("ioctl", errno)
}
Expand Down

0 comments on commit 4fd3221

Please sign in to comment.