netlink: Avoid undefined behaviour

Even though it is not dereferenced, it is UB to take the address of an
out of bounds array element.

Reviewed by: pouria, bz, des, adrian
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D57158
This commit is contained in:
Ed Maste committed 2026-05-22 10:21:11 -04:00
1 parent 0b2df68367
commit 1a4ad649cb
1 file changed
+2 -2
+2 -2
View File
@@ -127,13 +127,13 @@ genl_handle_message(struct nlmsghdr *hdr, struct nl_pstate *npt)
}
family_id = hdr->nlmsg_type - GENL_MIN_ID;
gf = &families[family_id];
if (__predict_false(family_id >= MAX_FAMILIES ||
gf->family_name == NULL)) {
families[family_id].family_name == NULL)) {
NLP_LOG(LOG_DEBUG, nlp, "invalid message type: %d",
hdr->nlmsg_type);
return (ENOTSUP);
}
gf = &families[family_id];
struct genlmsghdr *ghdr = (struct genlmsghdr *)(hdr + 1);