netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [libmnl PATCH] Improve nf-queue example: Avoid possible NULL pointer dereference
@ 2011-08-24 16:48 Thomas Jarosch
  0 siblings, 0 replies; only message in thread
From: Thomas Jarosch @ 2011-08-24 16:48 UTC (permalink / raw)
  To: netfilter-devel

Signed-off-by: Thomas Jarosch <thomas.jarosch@intra2net.com>
---
 examples/netfilter/nf-queue.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/examples/netfilter/nf-queue.c b/examples/netfilter/nf-queue.c
index 3658ba2..a0ace28 100644
--- a/examples/netfilter/nf-queue.c
+++ b/examples/netfilter/nf-queue.c
@@ -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;
 }
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2011-08-24 17:13 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-24 16:48 [libmnl PATCH] Improve nf-queue example: Avoid possible NULL pointer dereference Thomas Jarosch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).