Skip to content

Commit

Permalink
capability: Fix capHeader.pid type (#16)
Browse files Browse the repository at this point in the history
* Fix capHeader.pid type

In C, int is 4 bytes in 32 and 64-bit systems. In Go, int is a
8 bytes in 64-bit systems. Before this fix, pid was being ignored
because the kernel will always read 0 due to padding added between
version and pid fields.

* Update capability_linux.go
  • Loading branch information
fvoznika authored and syndtr committed Sep 16, 2018
1 parent a2f19b5 commit 7b553f5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions capability/capability/capability_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@ func newPid(pid int) (c Capabilities, err error) {
case linuxCapVer1:
p := new(capsV1)
p.hdr.version = capVers
p.hdr.pid = pid
p.hdr.pid = int32(pid)
c = p
case linuxCapVer2, linuxCapVer3:
p := new(capsV3)
p.hdr.version = capVers
p.hdr.pid = pid
p.hdr.pid = int32(pid)
c = p
default:
err = errUnknownVers
Expand Down
2 changes: 1 addition & 1 deletion capability/capability/syscall_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

type capHeader struct {
version uint32
pid int
pid int32
}

type capData struct {
Expand Down

0 comments on commit 7b553f5

Please sign in to comment.