Skip to content

Commit

Permalink
nl_linux: align message length before parsing.
Browse files Browse the repository at this point in the history
Signed-off-by: Nadia Pinaeva <[email protected]>
  • Loading branch information
npinaeva authored and aboch committed Apr 25, 2024
1 parent 578e95c commit 856e190
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions nl/nl_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -804,8 +804,9 @@ func (s *NetlinkSocket) Receive() ([]syscall.NetlinkMessage, *unix.SockaddrNetli
if nr < unix.NLMSG_HDRLEN {
return nil, nil, fmt.Errorf("Got short response from netlink")
}
rb2 := make([]byte, nr)
copy(rb2, rb[:nr])
msgLen := nlmAlignOf(nr)
rb2 := make([]byte, msgLen)
copy(rb2, rb[:msgLen])
nl, err := syscall.ParseNetlinkMessage(rb2)
if err != nil {
return nil, nil, err
Expand Down

0 comments on commit 856e190

Please sign in to comment.