Skip to content

netlink: fix UnmarshalBinary rejecting valid unpadded netlink messages#283

Merged
nickgarlis merged 1 commit intomdlayher:mainfrom
nickgarlis:fix-unmarshal-binary
Apr 13, 2026
Merged

netlink: fix UnmarshalBinary rejecting valid unpadded netlink messages#283
nickgarlis merged 1 commit intomdlayher:mainfrom
nickgarlis:fix-unmarshal-binary

Conversation

@nickgarlis
Copy link
Copy Markdown
Collaborator

parseMessagesIter passes an NLMSG_ALIGN'd slice to UnmarshalBinary, which then checks Header.Length != len(b). This fails for messages where nlmsg_len is not NLMSG_ALIGN'd. This is common with nfqueue, nflog, and conntrack events.

Change the strict equality to a bounds check and trim Data to nlmsg_len to exclude padding bytes.

parseMessagesIter passes an NLMSG_ALIGN'd slice to UnmarshalBinary,
which then checks Header.Length != len(b). This fails for messages
where nlmsg_len is not NLMSG_ALIGN'd. This is common with nfqueue,
nflog, and conntrack events.

Change the strict equality to a bounds check and trim Data to
nlmsg_len to exclude padding bytes.
@nickgarlis nickgarlis force-pushed the fix-unmarshal-binary branch from dca4e2b to 69d2228 Compare April 13, 2026 18:17
@nickgarlis nickgarlis merged commit 8788303 into mdlayher:main Apr 13, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant