From 8cb741a7dce0bcc9140a1f717028a8b4c80559f5 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Fri, 14 Jun 2013 14:31:08 +0200 Subject: dissector: icmpv6: Fix yet another possible null pointer dereference THe Coverity scanner discovered yet another possible null pointer dereference. Fix it by checking the return value of pkt_pull(). Also remove some trailing whitespaces in the region. Signed-off-by: Tobias Klauser --- proto_icmpv6.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'proto_icmpv6.c') diff --git a/proto_icmpv6.c b/proto_icmpv6.c index 35ed1ae..77c89b1 100644 --- a/proto_icmpv6.c +++ b/proto_icmpv6.c @@ -550,13 +550,21 @@ static int8_t dissect_neighb_disc_ops_15(struct pkt_buff *pkt, tprintf("Pad Len (%zu) ", pad_len); name_len = len - pad_len; - + tprintf("Name ("); while (name_len--) { - tprintf("%c", *pkt_pull(pkt,1)); + uint8_t *data = pkt_pull(pkt, 1); + + if (data == NULL) { + tprintf("%sINVALID%s", colorize_start_full(black, red), + colorize_end()); + return 0; + } + + tprintf("%c", *data); } tprintf(") "); - + tprintf("Padding ("); while (pad_len--) { -- cgit v1.2.3-54-g00ecf