Skip to contentSkip to conversation

Add NLMSG_OK checking to nfnl_get_msg_next

PATCH Applied Pablo Neira Ayuso 2 participants 2 messages Feb 12, 2006 – Feb 13, 2006 netfilter

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 Add NLMSG_OK checking to nfnl_get_msg_next

nfnl_get_msg_next must check is the message is OK after NLMSG_NEXT is called.

Signature · 1 line
Pablo

[LIBNFNETLINK] Add NLMSG_OK checking to nfnl_get_msg_next

nfnl_get_msg_next must check is the message is OK after NLMSG_NEXT is called.

src/libnfnetlink.c +5 -0
Index: libnfnetlink/src/libnfnetlink.c
===================================================================
@@ -861,6 +861,11 @@ struct nlmsghdr *nfnl_get_msg_next(struc
 	remain_len = (len - ((unsigned char *)h->last_nlhdr - buf));
 	nlh = NLMSG_NEXT(h->last_nlhdr, remain_len);
 
+	if (!NLMSG_OK(nlh, remain_len)) {
+		h->last_nlhdr = NULL;
+		return NULL;
+	}
+
 	h->last_nlhdr = nlh;
 
 	return nlh;
Applied
#1 lore raw
Quoted 2 lines · Pablo Neira Ayuso

nfnl_get_msg_next must check is the message is OK after NLMSG_NEXT is called.

thanks, applied.

Signature · 5 lines
- Harald Welte <[email protected]>                 http://netfilter.org/
============================================================================
  "Fragmentation is like classful addressing -- an interesting early
   architectural error that shows how much experimentation was going
   on while IP was being designed."                    -- Paul Vixie