From: Anoop Saldanha Date: Mon, 10 Dec 2012 19:14:54 +0000 (+0530) Subject: fix for bug 675. X-Git-Tag: suricata-1.4~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a30a1e59507c2e24b36e7085181d7eb2de17ab7d;p=thirdparty%2Fsuricata.git fix for bug 675. Fix icmpv6-csum to send the right length to calculate the csum. --- diff --git a/src/detect-csum.c b/src/detect-csum.c index 1cbde560f9..d8235158ca 100644 --- a/src/detect-csum.c +++ b/src/detect-csum.c @@ -801,8 +801,10 @@ int DetectICMPV6CsumMatch(ThreadVars *t, DetectEngineThreadCtx *det_ctx, { DetectCsumData *cd = (DetectCsumData *)m->ctx; - if (p->ip6h == NULL || p->icmpv6h == NULL || p->proto != IPPROTO_ICMPV6 || PKT_IS_PSEUDOPKT(p)) + if (p->ip6h == NULL || p->icmpv6h == NULL || p->proto != IPPROTO_ICMPV6 || PKT_IS_PSEUDOPKT(p) || + (p->pktlen - ((uint8_t *)p->icmpv6h - p->pkt)) <= 0) { return 0; + } if (p->flags & PKT_IGNORE_CHECKSUM) { return cd->valid; @@ -810,8 +812,8 @@ int DetectICMPV6CsumMatch(ThreadVars *t, DetectEngineThreadCtx *det_ctx, if (p->icmpv6vars.comp_csum == -1) p->icmpv6vars.comp_csum = ICMPV6CalculateChecksum(p->ip6h->s_ip6_addrs, - (uint16_t *)p->icmpv6h, - IPV6_GET_PLEN(p)); + (uint16_t *)p->icmpv6h, + p->pktlen - ((uint8_t *)p->icmpv6h - p->pkt)); if (p->icmpv6vars.comp_csum == p->icmpv6h->csum && cd->valid == 1) return 1;