netlink: do not crash when linux message translation fails.

CID:		1498889
MFC after:	2 weeks
This commit is contained in:
Alexander V. Chernikov 2023-02-18 17:41:48 +00:00
parent 8f7455a926
commit 453c7d6803

View File

@ -430,9 +430,11 @@ nl_receive_message(struct nlmsghdr *hdr, int remaining_length,
struct nlmsghdr *hdr_orig = hdr;
hdr = linux_netlink_p->msg_from_linux(nlp->nl_proto, hdr, npt);
if (hdr == NULL) {
npt->hdr = hdr_orig;
/* Failed to translate to kernel format. Report an error back */
hdr = hdr_orig;
npt->hdr = hdr;
if (hdr->nlmsg_flags & NLM_F_ACK)
nlmsg_ack(nlp, EAGAIN, hdr, npt);
nlmsg_ack(nlp, EOPNOTSUPP, hdr, npt);
return (0);
}
}