decode/tcp: improve pointer hygene

Avoid NULL pointer calculations.
pull/10971/head
Victor Julien 10 months ago committed by Victor Julien
parent 0dfa5793db
commit 86a363b1bc

@ -138,12 +138,11 @@ static void DecodeTCPOptions(Packet *p, const uint8_t *pkt, uint16_t pktlen)
break;
case TCP_OPT_SACK:
SCLogDebug("SACK option, len %u", olen);
if ((olen != 2) &&
(olen < TCP_OPT_SACK_MIN_LEN ||
olen > TCP_OPT_SACK_MAX_LEN ||
!((olen - 2) % 8 == 0)))
{
ENGINE_SET_EVENT(p,TCP_OPT_INVALID_LEN);
if (olen == 2) {
/* useless, but common empty SACK record */
} else if (olen < TCP_OPT_SACK_MIN_LEN || olen > TCP_OPT_SACK_MAX_LEN ||
!((olen - 2) % 8 == 0)) {
ENGINE_SET_EVENT(p, TCP_OPT_INVALID_LEN);
} else {
if (p->l4.vars.tcp.sack_set) {
ENGINE_SET_EVENT(p,TCP_OPT_DUPLICATE);

Loading…
Cancel
Save