summaryrefslogtreecommitdiff
path: root/dissector_sll.c
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2015-07-21 09:22:28 +0200
committerTobias Klauser <tklauser@distanz.ch>2015-07-21 09:22:28 +0200
commit98ed6adf069d0a1b89cd6f90657fce1136020bee (patch)
tree467ffa92bbbf68c81cc4236c703a242c980e5a0c /dissector_sll.c
parentb645a4371c3173fedff7274211b6834195a7ac18 (diff)
netsniff-ng: dissector_sll: Fix potential NULL dereference
pkt is dereferenced before it is checked. Move the dereference after the the check. Detected by the Coverity Scanner (CID 1312074 & 1312075). Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Diffstat (limited to 'dissector_sll.c')
-rw-r--r--dissector_sll.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/dissector_sll.c b/dissector_sll.c
index e2e5bfa..c9202df 100644
--- a/dissector_sll.c
+++ b/dissector_sll.c
@@ -35,12 +35,13 @@ static char *pkt_type2str(uint8_t pkttype)
static void sll_print_full(struct pkt_buff *pkt)
{
- struct sockaddr_ll *sll = pkt->sll;
+ struct sockaddr_ll *sll;
char addr_str[40] = {};
- if (!pkt || !sll)
+ if (!pkt || !pkt->sll)
return;
+ sll = pkt->sll;
tprintf(" [ Linux \"cooked\"");
tprintf(" Pkt Type %d (%s)", sll->sll_pkttype,
pkt_type2str(sll->sll_pkttype));
@@ -68,12 +69,13 @@ static void sll_print_full(struct pkt_buff *pkt)
static void sll_print_less(struct pkt_buff *pkt)
{
- struct sockaddr_ll *sll = pkt->sll;
+ struct sockaddr_ll *sll;
char addr_str[40] = {};
- if (!pkt || !sll)
+ if (!pkt || !pkt->sll)
return;
+ sll = pkt->sll;
tprintf(" Pkt Type %d (%s)", sll->sll_pkttype,
pkt_type2str(sll->sll_pkttype));
tprintf(", If Type %d (%s)", sll->sll_hatype,