Skip to contentSkip to conversation

Improve nf-queue example: Avoid possible NULL pointer dereference

PATCH New Thomas Jarosch 1 participant 1 message Aug 24, 2011 netfilter

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Improve nf-queue example: Avoid possible NULL pointer dereference

---
 examples/netfilter/nf-queue.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)
examples/netfilter/nf-queue.c +5 -3
index 3658ba2..a0ace28 100644
@@ -72,9 +72,11 @@ static int queue_cb(const struct nlmsghdr *nlh, void *data)
 	if (tb[NFQA_PACKET_HDR]) {
 		ph = mnl_attr_get_payload(tb[NFQA_PACKET_HDR]);
 		id = ntohl(ph->packet_id);
-	}
-	printf("packet received (id=%u hw=0x%04x hook=%u)\n",
-		id, ntohs(ph->hw_protocol), ph->hook);
+
+		printf("packet received (id=%u hw=0x%04x hook=%u)\n",
+			id, ntohs(ph->hw_protocol), ph->hook);
+	} else
+		printf("packet received without header\n");
 
 	return MNL_CB_OK + id;
 }
Signature · 1 line
1.7.4.4