Skip to content

Commit 856e190

Browse files
npinaevaaboch
authored andcommitted
nl_linux: align message length before parsing.
Signed-off-by: Nadia Pinaeva <[email protected]>
1 parent 578e95c commit 856e190

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

nl/nl_linux.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -804,8 +804,9 @@ func (s *NetlinkSocket) Receive() ([]syscall.NetlinkMessage, *unix.SockaddrNetli
804804
if nr < unix.NLMSG_HDRLEN {
805805
return nil, nil, fmt.Errorf("Got short response from netlink")
806806
}
807-
rb2 := make([]byte, nr)
808-
copy(rb2, rb[:nr])
807+
msgLen := nlmAlignOf(nr)
808+
rb2 := make([]byte, msgLen)
809+
copy(rb2, rb[:msgLen])
809810
nl, err := syscall.ParseNetlinkMessage(rb2)
810811
if err != nil {
811812
return nil, nil, err

0 commit comments

Comments
 (0)