From: Philippe Antoine Date: Wed, 8 Jun 2022 15:02:41 +0000 (+0200) Subject: defrag: do not cast pkt len to u16 X-Git-Tag: suricata-7.0.0-beta1~464 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9d6e5558f17a9ef2ad4a9b0ce83b8784d28f4ef6;p=thirdparty%2Fsuricata.git defrag: do not cast pkt len to u16 as it can overflow --- diff --git a/src/defrag.c b/src/defrag.c index 1bd34b5152..992d0205c2 100644 --- a/src/defrag.c +++ b/src/defrag.c @@ -840,8 +840,7 @@ DefragInsertFrag(ThreadVars *tv, DecodeThreadVars *dtv, DefragTracker *tracker, goto done; } memcpy(new->pkt, GET_PKT_DATA(p) + ltrim, GET_PKT_LEN(p) - ltrim); - DEBUG_VALIDATE_BUG_ON(GET_PKT_LEN(p) - ltrim > UINT16_MAX); - new->len = (uint16_t)(GET_PKT_LEN(p) - ltrim); + new->len = (GET_PKT_LEN(p) - ltrim); /* in case of unfragmentable exthdrs, update the 'next hdr' field * in the raw buffer so the reassembled packet will point to the * correct next header after stripping the frag header */