From: Victor Julien Date: Wed, 18 Sep 2019 10:21:04 +0000 (+0200) Subject: decode/ipv4: unittest to show parsing issue X-Git-Tag: suricata-5.0.0-rc1~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7bb3dfcfc80cfe59733da8ebc9d533fcb8c0d9d3;p=thirdparty%2Fsuricata.git decode/ipv4: unittest to show parsing issue --- diff --git a/src/decode-ipv4.c b/src/decode-ipv4.c index 09faae8a87..8a0bee951c 100644 --- a/src/decode-ipv4.c +++ b/src/decode-ipv4.c @@ -1631,6 +1631,36 @@ end: return result; } +/** + */ +static int DecodeEthernetTestIPv4Opt(void) +{ + uint8_t raw_eth[] = { + 0xae, 0x71, 0x00, 0x00, 0x00, 0x4b, 0x06, 0x90, 0x61, 0x02, 0x00, 0xcd, 0x88, 0x64, 0x11, 0x00, + 0x15, 0x00, 0x80, 0x64, 0x00, 0x21, 0x4c, 0x00, 0x00, 0x30, 0x42, 0xd6, 0xff, 0xff, 0xbd, 0x2f, + 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x01, 0x44, 0x05, 0x22, 0x02, 0x01 + }; + + DefragInit(); + + Packet *p = SCMalloc(SIZE_OF_PACKET); + FAIL_IF_NULL(p); + ThreadVars tv; + DecodeThreadVars dtv; + + memset(&dtv, 0, sizeof(DecodeThreadVars)); + memset(&tv, 0, sizeof(ThreadVars)); + memset(p, 0, SIZE_OF_PACKET); + + DecodeEthernet(&tv, &dtv, p, raw_eth, sizeof(raw_eth), NULL); + + SCFree(p); + DefragDestroy(); + PASS; +} + #endif /* UNITTESTS */ void DecodeIPV4RegisterTests(void) @@ -1674,6 +1704,7 @@ void DecodeIPV4RegisterTests(void) UtRegisterTest("DecodeIPV4DefragTest01", DecodeIPV4DefragTest01); UtRegisterTest("DecodeIPV4DefragTest02", DecodeIPV4DefragTest02); UtRegisterTest("DecodeIPV4DefragTest03", DecodeIPV4DefragTest03); + UtRegisterTest("DecodeEthernetTestIPv4Opt", DecodeEthernetTestIPv4Opt); #endif /* UNITTESTS */ } /**