mirror of https://github.com/vishvananda/netlink
nl_linux: align message length before parsing.
Signed-off-by: Nadia Pinaeva <n.m.pinaeva@gmail.com>
This commit is contained in:
parent
578e95cc31
commit
856e190dd7
|
@ -804,8 +804,9 @@ func (s *NetlinkSocket) Receive() ([]syscall.NetlinkMessage, *unix.SockaddrNetli
|
||||||
if nr < unix.NLMSG_HDRLEN {
|
if nr < unix.NLMSG_HDRLEN {
|
||||||
return nil, nil, fmt.Errorf("Got short response from netlink")
|
return nil, nil, fmt.Errorf("Got short response from netlink")
|
||||||
}
|
}
|
||||||
rb2 := make([]byte, nr)
|
msgLen := nlmAlignOf(nr)
|
||||||
copy(rb2, rb[:nr])
|
rb2 := make([]byte, msgLen)
|
||||||
|
copy(rb2, rb[:msgLen])
|
||||||
nl, err := syscall.ParseNetlinkMessage(rb2)
|
nl, err := syscall.ParseNetlinkMessage(rb2)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
|
|
Loading…
Reference in New Issue