From a19a249230202a437e6e98787a38cbc4c5951816 Mon Sep 17 00:00:00 2001 From: Anoop Saldanha Date: Wed, 1 Feb 2012 15:23:21 +0530 Subject: [PATCH] Set the packet protocol only if it can parsed without error --- src/decode-ipv4.c | 5 ++++- src/decode-ipv6.c | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/decode-ipv4.c b/src/decode-ipv4.c index 103164a9f6..199cc758b5 100644 --- a/src/decode-ipv4.c +++ b/src/decode-ipv4.c @@ -551,7 +551,7 @@ void DecodeIPV4(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt, #endif /* DEBUG */ /* check what next decoder to invoke */ - switch (p->proto = IPV4_GET_IPPROTO(p)) { + switch (IPV4_GET_IPPROTO(p)) { case IPPROTO_TCP: DecodeTCP(tv, dtv, p, pkt + IPV4_GET_HLEN(p), IPV4_GET_IPLEN(p) - IPV4_GET_HLEN(p), pq); @@ -597,6 +597,9 @@ void DecodeIPV4(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt, IPV4_GET_IPLEN(p) - IPV4_GET_HLEN(p), pq); } break; + default: + p->proto = IPV4_GET_IPPROTO(p); + break; } return; diff --git a/src/decode-ipv6.c b/src/decode-ipv6.c index e7619b5e2b..e7c49f723d 100644 --- a/src/decode-ipv6.c +++ b/src/decode-ipv6.c @@ -444,7 +444,7 @@ void DecodeIPV6(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt, #endif /* DEBUG */ /* now process the Ext headers and/or the L4 Layer */ - switch(p->proto = IPV6_GET_NH(p)) { + switch(IPV6_GET_NH(p)) { case IPPROTO_TCP: IPV6_SET_L4PROTO (p, IPPROTO_TCP); return DecodeTCP(tv, dtv, p, pkt + IPV6_HEADER_LEN, IPV6_GET_PLEN(p), pq); @@ -467,6 +467,9 @@ void DecodeIPV6(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt, case IPPROTO_ESP: DecodeIPV6ExtHdrs(tv, dtv, p, pkt + IPV6_HEADER_LEN, IPV6_GET_PLEN(p), pq); break; + default: + p->proto = IPV6_GET_NH(p); + break; } /* Pass to defragger if a fragment. */