Skip to contentSkip to conversation

libnfnetlink: BAD_SIZEOF

PATCH Applied Jiri Popelka 2 participants 2 messages Jun 10, 2011 – Jun 13, 2011 netfilter

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libnfnetlink: BAD_SIZEOF

static analysis (analysis based only on compiling of sources, not based on running of binary) of the code revealed the following problem:

libnfnetlink.c:481: Taking the size of pointer parameter "nlh" is suspicious. libnfnetlink.c:486: Taking the size of pointer parameter "nlh" is suspicious.

---
 src/libnfnetlink.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
src/libnfnetlink.c +2 -2
index 6e7afc6..2f962fc 100644
@@ -477,12 +477,12 @@ nfnl_parse_hdr(const struct nfnl_handle *nfnlh,
 
 	if (nlh->nlmsg_len == NLMSG_LENGTH(sizeof(struct nfgenmsg))) {
 		if (genmsg)
-			*genmsg = (void *)nlh + sizeof(nlh);
+			*genmsg = (void *)nlh + sizeof(*nlh);
 		return NULL;
 	}
 
 	if (genmsg)
-		*genmsg = (void *)nlh + sizeof(nlh);
+		*genmsg = (void *)nlh + sizeof(*nlh);
 
 	return (void *)nlh + NLMSG_LENGTH(sizeof(struct nfgenmsg));
 }
Signature · 1 line
1.7.5.2
maintainer Applied
#1 lore raw
Quoted 5 lines · Jiri Popelka

static analysis (analysis based only on compiling of sources, not based on running of binary) of the code revealed the following problem:

libnfnetlink.c:481: Taking the size of pointer parameter "nlh" is suspicious. libnfnetlink.c:486: Taking the size of pointer parameter "nlh" is suspicious.

Applied, thanks Jiri.