From: Juliana Fajardini Date: Mon, 2 May 2022 22:22:33 +0000 (-0300) Subject: unittests: alloc Packet with PacketGetFromAlloc X-Git-Tag: suricata-6.0.6~120 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ccd45345811dfa4c20a5755f7506dd3e81cfdd38;p=thirdparty%2Fsuricata.git unittests: alloc Packet with PacketGetFromAlloc Some unittests used SCMalloc for allocating new Packet the unittests. While this is valid, it leads to segmentation faults when we move to dynamic allocation of the maximum alerts allowed to be triggered by a single packet. This massive patch uses PacketGetFromAlloc, which initializes a Packet in such a way that any dynamic allocated structures within will also be initialized. Backport: edit a few more files/unittests that were not present in 7.0.x Related to Task #4207 (cherry picked from commit a6bda3596bdd1a0ac04afe5553609c6f7cba0023) --- diff --git a/src/decode-chdlc.c b/src/decode-chdlc.c index 55b4e0329b..3e0835ca73 100644 --- a/src/decode-chdlc.c +++ b/src/decode-chdlc.c @@ -77,15 +77,13 @@ static int DecodeCHDLCTest01 (void) 0x00,0x00,0x70,0x02,0x40,0x00,0x11,0x47,0x00,0x00, 0x02,0x04,0x05,0xb4,0x01,0x01,0x04,0x02 }; - Packet *p = SCMalloc(SIZE_OF_PACKET); - if (unlikely(p == NULL)) - return 0; + Packet *p = PacketGetFromAlloc(); + FAIL_IF_NULL(p); ThreadVars tv; DecodeThreadVars dtv; memset(&dtv, 0, sizeof(DecodeThreadVars)); memset(&tv, 0, sizeof(ThreadVars)); - memset(p, 0, SIZE_OF_PACKET); DecodeCHDLC(&tv, &dtv, p, raw, sizeof(raw)); diff --git a/src/decode-ethernet.c b/src/decode-ethernet.c index 556f5ed338..c843998426 100644 --- a/src/decode-ethernet.c +++ b/src/decode-ethernet.c @@ -89,7 +89,7 @@ static int DecodeEthernetTest01 (void) 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd }; - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; ThreadVars tv; @@ -97,7 +97,6 @@ static int DecodeEthernetTest01 (void) 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)); @@ -115,14 +114,13 @@ static int DecodeEthernetTestDceTooSmall(void) 0x94, 0x56, 0x00, 0x01, 0x89, 0x03, }; - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); 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)); @@ -151,14 +149,13 @@ static int DecodeEthernetTestDceNextTooSmall(void) 0x94, 0x56, 0x00, 0x01, }; - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); 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)); diff --git a/src/decode-icmpv4.c b/src/decode-icmpv4.c index 90d67bab40..b13bb4d7b3 100644 --- a/src/decode-icmpv4.c +++ b/src/decode-icmpv4.c @@ -379,7 +379,7 @@ static int DecodeICMPV4test01(void) 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab }; - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; ThreadVars tv; @@ -389,7 +389,6 @@ static int DecodeICMPV4test01(void) memset(&ip4h, 0, sizeof(IPV4Hdr)); memset(&tv, 0, sizeof(ThreadVars)); - memset(p, 0, SIZE_OF_PACKET); memset(&ip4h, 0, sizeof(IPV4Hdr)); memset(&dtv, 0, sizeof(DecodeThreadVars)); @@ -431,7 +430,7 @@ static int DecodeICMPV4test02(void) 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f }; - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; ThreadVars tv; @@ -441,7 +440,6 @@ static int DecodeICMPV4test02(void) memset(&ip4h, 0, sizeof(IPV4Hdr)); memset(&tv, 0, sizeof(ThreadVars)); - memset(p, 0, SIZE_OF_PACKET); memset(&dtv, 0, sizeof(DecodeThreadVars)); FlowInitConfig(FLOW_QUIET); @@ -480,7 +478,7 @@ static int DecodeICMPV4test03(void) 0x01, 0x11, 0xde, 0xfd, 0xc0, 0xa8, 0x01, 0x0d, 0xd1, 0x55, 0xe3, 0x93, 0x8b, 0x12, 0x82, 0xaa, 0x00, 0x28, 0x7c, 0xdd }; - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; ThreadVars tv; @@ -490,7 +488,6 @@ static int DecodeICMPV4test03(void) memset(&ip4h, 0, sizeof(IPV4Hdr)); memset(&tv, 0, sizeof(ThreadVars)); - memset(p, 0, SIZE_OF_PACKET); memset(&dtv, 0, sizeof(DecodeThreadVars)); FlowInitConfig(FLOW_QUIET); @@ -560,7 +557,7 @@ static int DecodeICMPV4test04(void) 0x3e, 0x36, 0x38, 0x7c, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x02, 0x16, 0xd0, 0x72, 0x04, 0x00, 0x00, 0x02, 0x04, 0x05, 0x8a, 0x04, 0x02, 0x08, 0x0a }; - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; ThreadVars tv; @@ -570,7 +567,6 @@ static int DecodeICMPV4test04(void) memset(&ip4h, 0, sizeof(IPV4Hdr)); memset(&tv, 0, sizeof(ThreadVars)); - memset(p, 0, SIZE_OF_PACKET); memset(&dtv, 0, sizeof(DecodeThreadVars)); FlowInitConfig(FLOW_QUIET); @@ -630,7 +626,7 @@ static int DecodeICMPV4test05(void) 0xd6, 0xbd, 0xc0, 0xa8, 0x02, 0x05, 0x3d, 0x23, 0xa1, 0x23, 0x04, 0x18, 0x00, 0x50, 0xd2, 0x08, 0xc2, 0x48, }; - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; ThreadVars tv; @@ -640,7 +636,6 @@ static int DecodeICMPV4test05(void) memset(&ip4h, 0, sizeof(IPV4Hdr)); memset(&tv, 0, sizeof(ThreadVars)); - memset(p, 0, SIZE_OF_PACKET); memset(&dtv, 0, sizeof(DecodeThreadVars)); FlowInitConfig(FLOW_QUIET); @@ -737,7 +732,7 @@ static int ICMPV4InvalidType07(void) 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x38}; - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; ThreadVars tv; @@ -747,7 +742,6 @@ static int ICMPV4InvalidType07(void) memset(&ip4h, 0, sizeof(IPV4Hdr)); memset(&tv, 0, sizeof(ThreadVars)); - memset(p, 0, SIZE_OF_PACKET); memset(&dtv, 0, sizeof(DecodeThreadVars)); FlowInitConfig(FLOW_QUIET); @@ -781,7 +775,7 @@ static int DecodeICMPV4test08(void) uint8_t raw_icmpv4[] = { 0x08, 0x00, 0x78, 0x47, 0xfc, 0x55, 0x00, 0x00 }; - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; ThreadVars tv; @@ -791,7 +785,6 @@ static int DecodeICMPV4test08(void) memset(&ip4h, 0, sizeof(IPV4Hdr)); memset(&tv, 0, sizeof(ThreadVars)); - memset(p, 0, SIZE_OF_PACKET); memset(&dtv, 0, sizeof(DecodeThreadVars)); FlowInitConfig(FLOW_QUIET); diff --git a/src/decode-icmpv6.c b/src/decode-icmpv6.c index db810bd375..8da4d54734 100644 --- a/src/decode-icmpv6.c +++ b/src/decode-icmpv6.c @@ -608,7 +608,7 @@ static int ICMPV6ParamProbTest01(void) 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x08, 0xb5, 0x99, 0xc3, 0xde, 0x40 }; - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); FAIL_IF_NULL(p); IPV6Hdr ip6h; ThreadVars tv; @@ -619,7 +619,6 @@ static int ICMPV6ParamProbTest01(void) ipv6dst = (uint32_t*) &raw_ipv6[24]; memset(&tv, 0, sizeof(ThreadVars)); - memset(p, 0, SIZE_OF_PACKET); memset(&dtv, 0, sizeof(DecodeThreadVars)); memset(&ip6h, 0, sizeof(IPV6Hdr)); @@ -664,7 +663,7 @@ static int ICMPV6PktTooBigTest01(void) 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }; - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); FAIL_IF_NULL(p); IPV6Hdr ip6h; ThreadVars tv; @@ -675,7 +674,6 @@ static int ICMPV6PktTooBigTest01(void) ipv6dst = (uint32_t*) &raw_ipv6[24]; memset(&tv, 0, sizeof(ThreadVars)); - memset(p, 0, SIZE_OF_PACKET); memset(&dtv, 0, sizeof(DecodeThreadVars)); memset(&ip6h, 0, sizeof(IPV6Hdr)); @@ -723,7 +721,7 @@ static int ICMPV6TimeExceedTest01(void) 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }; - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); FAIL_IF_NULL(p); IPV6Hdr ip6h; ThreadVars tv; @@ -734,7 +732,6 @@ static int ICMPV6TimeExceedTest01(void) ipv6dst = (uint32_t*) &raw_ipv6[24]; memset(&tv, 0, sizeof(ThreadVars)); - memset(p, 0, SIZE_OF_PACKET); memset(&dtv, 0, sizeof(DecodeThreadVars)); memset(&ip6h, 0, sizeof(IPV6Hdr)); @@ -782,7 +779,7 @@ static int ICMPV6DestUnreachTest01(void) 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }; - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); FAIL_IF_NULL(p); IPV6Hdr ip6h; ThreadVars tv; @@ -793,7 +790,6 @@ static int ICMPV6DestUnreachTest01(void) ipv6dst = (uint32_t*) &raw_ipv6[24]; memset(&tv, 0, sizeof(ThreadVars)); - memset(p, 0, SIZE_OF_PACKET); memset(&dtv, 0, sizeof(DecodeThreadVars)); memset(&ip6h, 0, sizeof(IPV6Hdr)); @@ -833,14 +829,13 @@ static int ICMPV6EchoReqTest01(void) 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0xe5, 0xa5, 0x25, 0xf0, 0x75, 0x23 }; - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); FAIL_IF_NULL(p); IPV6Hdr ip6h; ThreadVars tv; DecodeThreadVars dtv; memset(&tv, 0, sizeof(ThreadVars)); - memset(p, 0, SIZE_OF_PACKET); memset(&dtv, 0, sizeof(DecodeThreadVars)); memset(&ip6h, 0, sizeof(IPV6Hdr)); @@ -879,14 +874,13 @@ static int ICMPV6EchoRepTest01(void) 0x00, 0x00, 0x00, 0x00, 0x01, 0x81, 0x00, 0xe5, 0xa5, 0x25, 0xf0, 0x75, 0x23 }; - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); FAIL_IF_NULL(p); IPV6Hdr ip6h; ThreadVars tv; DecodeThreadVars dtv; memset(&tv, 0, sizeof(ThreadVars)); - memset(p, 0, SIZE_OF_PACKET); memset(&dtv, 0, sizeof(DecodeThreadVars)); memset(&ip6h, 0, sizeof(IPV6Hdr)); @@ -932,14 +926,13 @@ static int ICMPV6ParamProbTest02(void) 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x08, 0xb5, 0x99, 0xc3, 0xde, 0x40 }; - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); FAIL_IF_NULL(p); IPV6Hdr ip6h; ThreadVars tv; DecodeThreadVars dtv; memset(&tv, 0, sizeof(ThreadVars)); - memset(p, 0, SIZE_OF_PACKET); memset(&dtv, 0, sizeof(DecodeThreadVars)); memset(&ip6h, 0, sizeof(IPV6Hdr)); @@ -975,14 +968,13 @@ static int ICMPV6PktTooBigTest02(void) 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }; - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); FAIL_IF_NULL(p); IPV6Hdr ip6h; ThreadVars tv; DecodeThreadVars dtv; memset(&tv, 0, sizeof(ThreadVars)); - memset(p, 0, SIZE_OF_PACKET); memset(&dtv, 0, sizeof(DecodeThreadVars)); memset(&ip6h, 0, sizeof(IPV6Hdr)); @@ -1014,14 +1006,13 @@ static int ICMPV6TimeExceedTest02(void) /* The icmpv6 header is broken in the checksum (so we dont have a complete header) */ - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); FAIL_IF_NULL(p); IPV6Hdr ip6h; ThreadVars tv; DecodeThreadVars dtv; memset(&tv, 0, sizeof(ThreadVars)); - memset(p, 0, SIZE_OF_PACKET); memset(&dtv, 0, sizeof(DecodeThreadVars)); memset(&ip6h, 0, sizeof(IPV6Hdr)); @@ -1055,14 +1046,13 @@ static int ICMPV6DestUnreachTest02(void) 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); FAIL_IF_NULL(p); IPV6Hdr ip6h; ThreadVars tv; DecodeThreadVars dtv; memset(&tv, 0, sizeof(ThreadVars)); - memset(p, 0, SIZE_OF_PACKET); memset(&dtv, 0, sizeof(DecodeThreadVars)); memset(&ip6h, 0, sizeof(IPV6Hdr)); @@ -1092,14 +1082,13 @@ static int ICMPV6EchoReqTest02(void) 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x01, 0xe5, 0xa5, 0x25, 0xf0, 0x75, 0x23 }; - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); FAIL_IF_NULL(p); IPV6Hdr ip6h; ThreadVars tv; DecodeThreadVars dtv; memset(&tv, 0, sizeof(ThreadVars)); - memset(p, 0, SIZE_OF_PACKET); memset(&dtv, 0, sizeof(DecodeThreadVars)); memset(&ip6h, 0, sizeof(IPV6Hdr)); @@ -1129,14 +1118,13 @@ static int ICMPV6EchoRepTest02(void) 0x00, 0x00, 0x00, 0x00, 0x01, 0x81, 0x01, 0xe5, 0xa5, 0x25, 0xf0, 0x75, 0x23 }; - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); FAIL_IF_NULL(p); IPV6Hdr ip6h; ThreadVars tv; DecodeThreadVars dtv; memset(&tv, 0, sizeof(ThreadVars)); - memset(p, 0, SIZE_OF_PACKET); memset(&dtv, 0, sizeof(DecodeThreadVars)); memset(&ip6h, 0, sizeof(IPV6Hdr)); @@ -1169,14 +1157,13 @@ static int ICMPV6PayloadTest01(void) 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); FAIL_IF_NULL(p); IPV6Hdr ip6h; ThreadVars tv; DecodeThreadVars dtv; memset(&tv, 0, sizeof(ThreadVars)); - memset(p, 0, SIZE_OF_PACKET); memset(&dtv, 0, sizeof(DecodeThreadVars)); memset(&ip6h, 0, sizeof(IPV6Hdr)); @@ -1203,14 +1190,13 @@ static int ICMPV6RouterSolicitTestKnownCode(void) 0x85, 0x00, 0xbe, 0xb0, 0x00, 0x00, 0x00, 0x00 }; - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); FAIL_IF_NULL(p); IPV6Hdr ip6h; ThreadVars tv; DecodeThreadVars dtv; memset(&tv, 0, sizeof(ThreadVars)); - memset(p, 0, SIZE_OF_PACKET); memset(&dtv, 0, sizeof(DecodeThreadVars)); memset(&ip6h, 0, sizeof(IPV6Hdr)); @@ -1236,14 +1222,13 @@ static int ICMPV6RouterSolicitTestUnknownCode(void) 0x85, 0x01, 0xbe, 0xaf, 0x00, 0x00, 0x00, 0x00 }; - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); FAIL_IF_NULL(p); IPV6Hdr ip6h; ThreadVars tv; DecodeThreadVars dtv; memset(&tv, 0, sizeof(ThreadVars)); - memset(p, 0, SIZE_OF_PACKET); memset(&dtv, 0, sizeof(DecodeThreadVars)); memset(&ip6h, 0, sizeof(IPV6Hdr)); @@ -1269,14 +1254,13 @@ static int ICMPV6RouterAdvertTestKnownCode(void) 0x86, 0x00, 0xbd, 0xb0, 0x00, 0x00, 0x00, 0x00 }; - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); FAIL_IF_NULL(p); IPV6Hdr ip6h; ThreadVars tv; DecodeThreadVars dtv; memset(&tv, 0, sizeof(ThreadVars)); - memset(p, 0, SIZE_OF_PACKET); memset(&dtv, 0, sizeof(DecodeThreadVars)); memset(&ip6h, 0, sizeof(IPV6Hdr)); @@ -1302,14 +1286,13 @@ static int ICMPV6RouterAdvertTestUnknownCode(void) 0x86, 0x01, 0xbd, 0xaf, 0x00, 0x00, 0x00, 0x00 }; - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); FAIL_IF_NULL(p); IPV6Hdr ip6h; ThreadVars tv; DecodeThreadVars dtv; memset(&tv, 0, sizeof(ThreadVars)); - memset(p, 0, SIZE_OF_PACKET); memset(&dtv, 0, sizeof(DecodeThreadVars)); memset(&ip6h, 0, sizeof(IPV6Hdr)); @@ -1335,14 +1318,13 @@ static int ICMPV6NeighbourSolicitTestKnownCode(void) 0x87, 0x00, 0xbc, 0xb0, 0x00, 0x00, 0x00, 0x00 }; - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); FAIL_IF_NULL(p); IPV6Hdr ip6h; ThreadVars tv; DecodeThreadVars dtv; memset(&tv, 0, sizeof(ThreadVars)); - memset(p, 0, SIZE_OF_PACKET); memset(&dtv, 0, sizeof(DecodeThreadVars)); memset(&ip6h, 0, sizeof(IPV6Hdr)); @@ -1368,14 +1350,13 @@ static int ICMPV6NeighbourSolicitTestUnknownCode(void) 0x87, 0x01, 0xbc, 0xaf, 0x00, 0x00, 0x00, 0x00 }; - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); FAIL_IF_NULL(p); IPV6Hdr ip6h; ThreadVars tv; DecodeThreadVars dtv; memset(&tv, 0, sizeof(ThreadVars)); - memset(p, 0, SIZE_OF_PACKET); memset(&dtv, 0, sizeof(DecodeThreadVars)); memset(&ip6h, 0, sizeof(IPV6Hdr)); @@ -1401,14 +1382,13 @@ static int ICMPV6NeighbourAdvertTestKnownCode(void) 0x88, 0x00, 0xbb, 0xb0, 0x00, 0x00, 0x00, 0x00 }; - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); FAIL_IF_NULL(p); IPV6Hdr ip6h; ThreadVars tv; DecodeThreadVars dtv; memset(&tv, 0, sizeof(ThreadVars)); - memset(p, 0, SIZE_OF_PACKET); memset(&dtv, 0, sizeof(DecodeThreadVars)); memset(&ip6h, 0, sizeof(IPV6Hdr)); @@ -1434,14 +1414,13 @@ static int ICMPV6NeighbourAdvertTestUnknownCode(void) 0x88, 0x01, 0xbb, 0xaf, 0x00, 0x00, 0x00, 0x00 }; - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); FAIL_IF_NULL(p); IPV6Hdr ip6h; ThreadVars tv; DecodeThreadVars dtv; memset(&tv, 0, sizeof(ThreadVars)); - memset(p, 0, SIZE_OF_PACKET); memset(&dtv, 0, sizeof(DecodeThreadVars)); memset(&ip6h, 0, sizeof(IPV6Hdr)); @@ -1467,14 +1446,13 @@ static int ICMPV6RedirectTestKnownCode(void) 0x89, 0x00, 0xba, 0xb0, 0x00, 0x00, 0x00, 0x00 }; - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); FAIL_IF_NULL(p); IPV6Hdr ip6h; ThreadVars tv; DecodeThreadVars dtv; memset(&tv, 0, sizeof(ThreadVars)); - memset(p, 0, SIZE_OF_PACKET); memset(&dtv, 0, sizeof(DecodeThreadVars)); memset(&ip6h, 0, sizeof(IPV6Hdr)); @@ -1500,14 +1478,13 @@ static int ICMPV6RedirectTestUnknownCode(void) 0x89, 0x01, 0xba, 0xaf, 0x00, 0x00, 0x00, 0x00 }; - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); FAIL_IF_NULL(p); IPV6Hdr ip6h; ThreadVars tv; DecodeThreadVars dtv; memset(&tv, 0, sizeof(ThreadVars)); - memset(p, 0, SIZE_OF_PACKET); memset(&dtv, 0, sizeof(DecodeThreadVars)); memset(&ip6h, 0, sizeof(IPV6Hdr)); @@ -1550,14 +1527,13 @@ static int ICMPV6CalculateValidChecksumWithFCS(void) }; uint16_t csum = *(((uint16_t *)(raw_ipv6 + 64))); - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); FAIL_IF_NULL(p); IPV6Hdr ip6h; ThreadVars tv; DecodeThreadVars dtv; memset(&tv, 0, sizeof(ThreadVars)); - memset(p, 0, SIZE_OF_PACKET); memset(&dtv, 0, sizeof(DecodeThreadVars)); memset(&ip6h, 0, sizeof(IPV6Hdr)); diff --git a/src/decode-ipv4.c b/src/decode-ipv4.c index 825200500f..62f4674280 100644 --- a/src/decode-ipv4.c +++ b/src/decode-ipv4.c @@ -1625,14 +1625,13 @@ static int DecodeEthernetTestIPv4Opt(void) DefragInit(); - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); 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)); diff --git a/src/decode-mpls.c b/src/decode-mpls.c index 6de6e49e2d..059521d1d7 100644 --- a/src/decode-mpls.c +++ b/src/decode-mpls.c @@ -142,7 +142,7 @@ static int DecodeMPLSTestHeaderTooSmall(void) 0x00, 0x00, 0x11 }; - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) { return 0; } @@ -151,7 +151,6 @@ static int DecodeMPLSTestHeaderTooSmall(void) memset(&dtv, 0, sizeof(DecodeThreadVars)); memset(&tv, 0, sizeof(ThreadVars)); - memset(p, 0, SIZE_OF_PACKET); DecodeMPLS(&tv, &dtv, p, pkt, sizeof(pkt)); @@ -230,7 +229,7 @@ static int DecodeMPLSTestBadLabelRouterAlert(void) 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd }; - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) { return 0; } @@ -239,7 +238,6 @@ static int DecodeMPLSTestBadLabelRouterAlert(void) memset(&dtv, 0, sizeof(DecodeThreadVars)); memset(&tv, 0, sizeof(ThreadVars)); - memset(p, 0, SIZE_OF_PACKET); DecodeMPLS(&tv, &dtv, p, pkt, sizeof(pkt)); @@ -270,7 +268,7 @@ static int DecodeMPLSTestBadLabelImplicitNull(void) 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd }; - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) { return 0; } @@ -279,7 +277,6 @@ static int DecodeMPLSTestBadLabelImplicitNull(void) memset(&dtv, 0, sizeof(DecodeThreadVars)); memset(&tv, 0, sizeof(ThreadVars)); - memset(p, 0, SIZE_OF_PACKET); DecodeMPLS(&tv, &dtv, p, pkt, sizeof(pkt)); @@ -310,7 +307,7 @@ static int DecodeMPLSTestBadLabelReserved(void) 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd }; - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) { return 0; } @@ -319,7 +316,6 @@ static int DecodeMPLSTestBadLabelReserved(void) memset(&dtv, 0, sizeof(DecodeThreadVars)); memset(&tv, 0, sizeof(ThreadVars)); - memset(p, 0, SIZE_OF_PACKET); DecodeMPLS(&tv, &dtv, p, pkt, sizeof(pkt)); @@ -354,7 +350,7 @@ static int DecodeMPLSTestUnknownPayloadType(void) 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd }; - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) { return 0; } @@ -363,7 +359,6 @@ static int DecodeMPLSTestUnknownPayloadType(void) memset(&dtv, 0, sizeof(DecodeThreadVars)); memset(&tv, 0, sizeof(ThreadVars)); - memset(p, 0, SIZE_OF_PACKET); DecodeMPLS(&tv, &dtv, p, pkt, sizeof(pkt)); diff --git a/src/detect-content.c b/src/detect-content.c index b7e8da135f..0b3d5eed13 100644 --- a/src/detect-content.c +++ b/src/detect-content.c @@ -1005,7 +1005,7 @@ static int DetectContentLongPatternMatchTest(uint8_t *raw_eth_pkt, uint16_t pkts { int result = 0; - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; DecodeThreadVars dtv; @@ -1013,7 +1013,6 @@ static int DetectContentLongPatternMatchTest(uint8_t *raw_eth_pkt, uint16_t pkts ThreadVars th_v; DetectEngineThreadCtx *det_ctx = NULL; - memset(p, 0, SIZE_OF_PACKET); memset(&dtv, 0, sizeof(DecodeThreadVars)); memset(&th_v, 0, sizeof(th_v)); diff --git a/src/detect-dsize.c b/src/detect-dsize.c index 164bd05602..5d34401409 100644 --- a/src/detect-dsize.c +++ b/src/detect-dsize.c @@ -887,7 +887,7 @@ static int DetectDsizeIcmpv6Test01 (void) 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }; - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; IPV6Hdr ip6h; @@ -898,7 +898,6 @@ static int DetectDsizeIcmpv6Test01 (void) DetectEngineThreadCtx *det_ctx = NULL; memset(&tv, 0, sizeof(ThreadVars)); - memset(p, 0, SIZE_OF_PACKET); memset(&dtv, 0, sizeof(DecodeThreadVars)); memset(&ip6h, 0, sizeof(IPV6Hdr)); memset(&th_v, 0, sizeof(ThreadVars)); diff --git a/src/detect-engine-event.c b/src/detect-engine-event.c index f81186e825..50b1f105ca 100644 --- a/src/detect-engine-event.c +++ b/src/detect-engine-event.c @@ -341,7 +341,7 @@ static int EngineEventTestParse05 (void) */ static int EngineEventTestParse06 (void) { - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; ThreadVars tv; @@ -351,7 +351,6 @@ static int EngineEventTestParse06 (void) memset(&tv, 0, sizeof(ThreadVars)); - memset(p, 0, SIZE_OF_PACKET); ENGINE_SET_EVENT(p,PPP_PKT_TOO_SMALL); diff --git a/src/detect-flowbits.c b/src/detect-flowbits.c index 1b110b608c..adc71a73a6 100644 --- a/src/detect-flowbits.c +++ b/src/detect-flowbits.c @@ -944,7 +944,7 @@ static int FlowBitsTestSig06(void) "Host: one.example.org\r\n" "\r\n"; uint16_t buflen = strlen((char *)buf); - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); FAIL_IF_NULL(p); Signature *s = NULL; ThreadVars th_v; @@ -955,7 +955,6 @@ static int FlowBitsTestSig06(void) int result = 0; uint32_t idx = 0; - memset(p, 0, SIZE_OF_PACKET); memset(&th_v, 0, sizeof(th_v)); memset(&f, 0, sizeof(Flow)); memset(&flowvar, 0, sizeof(GenericVar)); @@ -1018,7 +1017,7 @@ static int FlowBitsTestSig07(void) "Host: one.example.org\r\n" "\r\n"; uint16_t buflen = strlen((char *)buf); - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); FAIL_IF_NULL(p); Signature *s = NULL; ThreadVars th_v; @@ -1029,7 +1028,6 @@ static int FlowBitsTestSig07(void) int result = 0; uint32_t idx = 0; - memset(p, 0, SIZE_OF_PACKET); memset(&th_v, 0, sizeof(th_v)); memset(&f, 0, sizeof(Flow)); memset(&flowvar, 0, sizeof(GenericVar)); @@ -1094,7 +1092,7 @@ static int FlowBitsTestSig08(void) "Host: one.example.org\r\n" "\r\n"; uint16_t buflen = strlen((char *)buf); - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; Signature *s = NULL; @@ -1106,7 +1104,6 @@ static int FlowBitsTestSig08(void) int result = 0; uint32_t idx = 0; - memset(p, 0, SIZE_OF_PACKET); memset(&th_v, 0, sizeof(th_v)); memset(&f, 0, sizeof(Flow)); memset(&flowvar, 0, sizeof(GenericVar)); @@ -1171,7 +1168,7 @@ static int FlowBitsTestSig09(void) "Host: one.example.org\r\n" "\r\n"; uint16_t buflen = strlen((char *)buf); - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); FAIL_IF_NULL(p); Signature *s = NULL; ThreadVars th_v; @@ -1179,7 +1176,6 @@ static int FlowBitsTestSig09(void) DetectEngineCtx *de_ctx = NULL; Flow f; - memset(p, 0, SIZE_OF_PACKET); memset(&th_v, 0, sizeof(th_v)); memset(&f, 0, sizeof(Flow)); @@ -1238,7 +1234,7 @@ static int FlowBitsTestSig10(void) "Host: one.example.org\r\n" "\r\n"; uint16_t buflen = strlen((char *)buf); - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); FAIL_IF_NULL(p); Signature *s = NULL; ThreadVars th_v; @@ -1246,7 +1242,6 @@ static int FlowBitsTestSig10(void) DetectEngineCtx *de_ctx = NULL; Flow f; - memset(p, 0, SIZE_OF_PACKET); memset(&th_v, 0, sizeof(th_v)); memset(&f, 0, sizeof(Flow)); @@ -1308,7 +1303,7 @@ static int FlowBitsTestSig11(void) "Host: one.example.org\r\n" "\r\n"; uint16_t buflen = strlen((char *)buf); - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); FAIL_IF_NULL(p); Signature *s = NULL; ThreadVars th_v; @@ -1316,7 +1311,6 @@ static int FlowBitsTestSig11(void) DetectEngineCtx *de_ctx = NULL; Flow f; - memset(p, 0, SIZE_OF_PACKET); memset(&th_v, 0, sizeof(th_v)); memset(&f, 0, sizeof(Flow)); diff --git a/src/detect-fragbits.c b/src/detect-fragbits.c index 81092a580b..bc10b860c1 100644 --- a/src/detect-fragbits.c +++ b/src/detect-fragbits.c @@ -467,7 +467,7 @@ static int FragBitsTestParse03 (void) 0x0b ,0xc0 ,0x9f ,0x00 ,0x01 ,0x00 ,0x01 ,0x00, 0x00 ,0x0e ,0x10 ,0x00 ,0x04 ,0x81 ,0x6f ,0x0b, 0x51}; - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); FAIL_IF(unlikely(p == NULL)); ThreadVars tv; DecodeThreadVars dtv; @@ -477,7 +477,6 @@ static int FragBitsTestParse03 (void) SigMatch *sm = NULL; memset(&tv, 0, sizeof(ThreadVars)); - memset(p, 0, SIZE_OF_PACKET); memset(&dtv, 0, sizeof(DecodeThreadVars)); memset(&ipv4h, 0, sizeof(IPV4Hdr)); dtv.app_tctx = AppLayerGetCtxThread(&tv); @@ -554,7 +553,7 @@ static int FragBitsTestParse04 (void) 0x0b ,0xc0 ,0x9f ,0x00 ,0x01 ,0x00 ,0x01 ,0x00, 0x00 ,0x0e ,0x10 ,0x00 ,0x04 ,0x81 ,0x6f ,0x0b, 0x51}; - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); FAIL_IF(unlikely(p == NULL)); ThreadVars tv; DecodeThreadVars dtv; @@ -564,7 +563,6 @@ static int FragBitsTestParse04 (void) SigMatch *sm = NULL; memset(&tv, 0, sizeof(ThreadVars)); - memset(p, 0, SIZE_OF_PACKET); memset(&dtv, 0, sizeof(DecodeThreadVars)); memset(&ipv4h, 0, sizeof(IPV4Hdr)); dtv.app_tctx = AppLayerGetCtxThread(&tv); diff --git a/src/detect-fragoffset.c b/src/detect-fragoffset.c index 0a793267f6..bc179b5c51 100644 --- a/src/detect-fragoffset.c +++ b/src/detect-fragoffset.c @@ -379,7 +379,7 @@ static int DetectFragOffsetParseTest03 (void) static int DetectFragOffsetMatchTest01 (void) { int result = 0; - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; Signature *s = NULL; @@ -388,7 +388,6 @@ static int DetectFragOffsetMatchTest01 (void) DetectEngineThreadCtx *det_ctx = NULL; IPV4Hdr ip4h; - memset(p, 0, SIZE_OF_PACKET); memset(&ip4h, 0, sizeof(IPV4Hdr)); memset(&dtv, 0, sizeof(DecodeThreadVars)); memset(&th_v, 0, sizeof(ThreadVars)); diff --git a/src/detect-ftpbounce.c b/src/detect-ftpbounce.c index 77ac3e9891..b60b2df68c 100644 --- a/src/detect-ftpbounce.c +++ b/src/detect-ftpbounce.c @@ -437,7 +437,7 @@ static int DetectFtpbounceTestALMatch03(void) TcpSession ssn; Flow f; - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; Signature *s = NULL; @@ -446,7 +446,6 @@ static int DetectFtpbounceTestALMatch03(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); - memset(p, 0, SIZE_OF_PACKET); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); diff --git a/src/detect-hostbits.c b/src/detect-hostbits.c index 9e33138dd1..822750234f 100644 --- a/src/detect-hostbits.c +++ b/src/detect-hostbits.c @@ -563,7 +563,6 @@ static int HostBitsTestSig01(void) DetectEngineCtx *de_ctx = NULL; memset(&th_v, 0, sizeof(th_v)); - memset(p, 0, SIZE_OF_PACKET); p->src.family = AF_INET; p->dst.family = AF_INET; p->payload = buf; @@ -656,7 +655,7 @@ static int HostBitsTestSig03(void) "Host: one.example.org\r\n" "\r\n"; uint16_t buflen = strlen((char *)buf); - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; Signature *s = NULL; @@ -745,7 +744,6 @@ static int HostBitsTestSig04(void) int idx = 0; memset(&th_v, 0, sizeof(th_v)); - memset(p, 0, SIZE_OF_PACKET); p->src.family = AF_INET; p->dst.family = AF_INET; p->payload = buf; @@ -1070,7 +1068,6 @@ static int HostBitsTestSig07(void) Flow f; int result = 0; - memset(p, 0, SIZE_OF_PACKET); memset(&th_v, 0, sizeof(th_v)); memset(&f, 0, sizeof(Flow)); @@ -1145,7 +1142,6 @@ static int HostBitsTestSig08(void) DetectEngineCtx *de_ctx = NULL; Flow f; - memset(p, 0, SIZE_OF_PACKET); memset(&th_v, 0, sizeof(th_v)); memset(&f, 0, sizeof(Flow)); diff --git a/src/detect-ipopts.c b/src/detect-ipopts.c index 3867e56894..52a8833d1a 100644 --- a/src/detect-ipopts.c +++ b/src/detect-ipopts.c @@ -260,7 +260,7 @@ static int IpOptsTestParse02 (void) */ static int IpOptsTestParse03 (void) { - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; ThreadVars tv; @@ -270,7 +270,6 @@ static int IpOptsTestParse03 (void) IPV4Hdr ip4h; memset(&tv, 0, sizeof(ThreadVars)); - memset(p, 0, SIZE_OF_PACKET); memset(&ip4h, 0, sizeof(IPV4Hdr)); p->ip4h = &ip4h; @@ -310,7 +309,7 @@ error: */ static int IpOptsTestParse04 (void) { - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; ThreadVars tv; @@ -320,7 +319,6 @@ static int IpOptsTestParse04 (void) IPV4Hdr ip4h; memset(&tv, 0, sizeof(ThreadVars)); - memset(p, 0, SIZE_OF_PACKET); memset(&ip4h, 0, sizeof(IPV4Hdr)); p->ip4h = &ip4h; diff --git a/src/detect-ipproto.c b/src/detect-ipproto.c index fcee601e92..a2b452c6f8 100644 --- a/src/detect-ipproto.c +++ b/src/detect-ipproto.c @@ -1915,10 +1915,9 @@ static int DetectIPProtoTestSig2(void) 0x4a, 0xea, 0x7a, 0x8e, }; - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; - memset(p, 0, SIZE_OF_PACKET); DecodeThreadVars dtv; ThreadVars th_v; diff --git a/src/detect-parse.c b/src/detect-parse.c index 199840b809..46ae41fff0 100644 --- a/src/detect-parse.c +++ b/src/detect-parse.c @@ -3624,7 +3624,7 @@ static int SigTestBidirec04 (void) 0x6b,0x65,0x65,0x70,0x2d,0x61,0x6c,0x69, 0x76,0x65,0x0d,0x0a,0x0d,0x0a }; /* end rawpkt1_ether */ - p = SCMalloc(SIZE_OF_PACKET); + p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; DecodeThreadVars dtv; @@ -3632,7 +3632,6 @@ static int SigTestBidirec04 (void) DetectEngineThreadCtx *det_ctx; memset(&th_v, 0, sizeof(th_v)); - memset(p, 0, SIZE_OF_PACKET); FlowInitConfig(FLOW_QUIET); DecodeEthernet(&th_v, &dtv, p, rawpkt1_ether, sizeof(rawpkt1_ether)); diff --git a/src/detect-tcp-flags.c b/src/detect-tcp-flags.c index 62decaaa46..d3e548d55d 100644 --- a/src/detect-tcp-flags.c +++ b/src/detect-tcp-flags.c @@ -653,7 +653,7 @@ static int FlagsTestParse02 (void) */ static int FlagsTestParse03 (void) { - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; ThreadVars tv; @@ -664,7 +664,6 @@ static int FlagsTestParse03 (void) TCPHdr tcph; memset(&tv, 0, sizeof(ThreadVars)); - memset(p, 0, SIZE_OF_PACKET); memset(&ipv4h, 0, sizeof(IPV4Hdr)); memset(&tcph, 0, sizeof(TCPHdr)); @@ -708,7 +707,7 @@ error: */ static int FlagsTestParse04 (void) { - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; ThreadVars tv; @@ -719,7 +718,6 @@ static int FlagsTestParse04 (void) TCPHdr tcph; memset(&tv, 0, sizeof(ThreadVars)); - memset(p, 0, SIZE_OF_PACKET); memset(&ipv4h, 0, sizeof(IPV4Hdr)); memset(&tcph, 0, sizeof(TCPHdr)); @@ -764,7 +762,7 @@ error: */ static int FlagsTestParse05 (void) { - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; ThreadVars tv; @@ -775,7 +773,6 @@ static int FlagsTestParse05 (void) TCPHdr tcph; memset(&tv, 0, sizeof(ThreadVars)); - memset(p, 0, SIZE_OF_PACKET); memset(&ipv4h, 0, sizeof(IPV4Hdr)); memset(&tcph, 0, sizeof(TCPHdr)); @@ -820,7 +817,7 @@ error: */ static int FlagsTestParse06 (void) { - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; ThreadVars tv; @@ -831,7 +828,6 @@ static int FlagsTestParse06 (void) TCPHdr tcph; memset(&tv, 0, sizeof(ThreadVars)); - memset(p, 0, SIZE_OF_PACKET); memset(&ipv4h, 0, sizeof(IPV4Hdr)); memset(&tcph, 0, sizeof(TCPHdr)); @@ -875,7 +871,7 @@ error: */ static int FlagsTestParse07 (void) { - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; ThreadVars tv; @@ -886,7 +882,6 @@ static int FlagsTestParse07 (void) TCPHdr tcph; memset(&tv, 0, sizeof(ThreadVars)); - memset(p, 0, SIZE_OF_PACKET); memset(&ipv4h, 0, sizeof(IPV4Hdr)); memset(&tcph, 0, sizeof(TCPHdr)); @@ -931,7 +926,7 @@ error: */ static int FlagsTestParse08 (void) { - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; ThreadVars tv; @@ -942,7 +937,6 @@ static int FlagsTestParse08 (void) TCPHdr tcph; memset(&tv, 0, sizeof(ThreadVars)); - memset(p, 0, SIZE_OF_PACKET); memset(&ipv4h, 0, sizeof(IPV4Hdr)); memset(&tcph, 0, sizeof(TCPHdr)); @@ -986,7 +980,7 @@ error: */ static int FlagsTestParse09 (void) { - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; ThreadVars tv; @@ -997,7 +991,6 @@ static int FlagsTestParse09 (void) TCPHdr tcph; memset(&tv, 0, sizeof(ThreadVars)); - memset(p, 0, SIZE_OF_PACKET); memset(&ipv4h, 0, sizeof(IPV4Hdr)); memset(&tcph, 0, sizeof(TCPHdr)); @@ -1041,7 +1034,7 @@ error: */ static int FlagsTestParse10 (void) { - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; ThreadVars tv; @@ -1052,7 +1045,6 @@ static int FlagsTestParse10 (void) TCPHdr tcph; memset(&tv, 0, sizeof(ThreadVars)); - memset(p, 0, SIZE_OF_PACKET); memset(&ipv4h, 0, sizeof(IPV4Hdr)); memset(&tcph, 0, sizeof(TCPHdr)); @@ -1096,7 +1088,7 @@ error: */ static int FlagsTestParse11 (void) { - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; ThreadVars tv; @@ -1107,7 +1099,6 @@ static int FlagsTestParse11 (void) TCPHdr tcph; memset(&tv, 0, sizeof(ThreadVars)); - memset(p, 0, SIZE_OF_PACKET); memset(&ipv4h, 0, sizeof(IPV4Hdr)); memset(&tcph, 0, sizeof(TCPHdr)); @@ -1152,7 +1143,7 @@ error: */ static int FlagsTestParse12 (void) { - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; ThreadVars tv; @@ -1163,7 +1154,6 @@ static int FlagsTestParse12 (void) TCPHdr tcph; memset(&tv, 0, sizeof(ThreadVars)); - memset(p, 0, SIZE_OF_PACKET); memset(&ipv4h, 0, sizeof(IPV4Hdr)); memset(&tcph, 0, sizeof(TCPHdr)); @@ -1239,7 +1229,7 @@ static int FlagsTestParse14(void) static int FlagsTestParse15(void) { - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; ThreadVars tv; @@ -1250,7 +1240,6 @@ static int FlagsTestParse15(void) TCPHdr tcph; memset(&tv, 0, sizeof(ThreadVars)); - memset(p, 0, SIZE_OF_PACKET); memset(&ipv4h, 0, sizeof(IPV4Hdr)); memset(&tcph, 0, sizeof(TCPHdr)); @@ -1292,7 +1281,7 @@ error: static int FlagsTestParse16(void) { - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; ThreadVars tv; @@ -1303,7 +1292,6 @@ static int FlagsTestParse16(void) TCPHdr tcph; memset(&tv, 0, sizeof(ThreadVars)); - memset(p, 0, SIZE_OF_PACKET); memset(&ipv4h, 0, sizeof(IPV4Hdr)); memset(&tcph, 0, sizeof(TCPHdr)); @@ -1348,7 +1336,7 @@ error: */ static int FlagsTestParse17(void) { - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; ThreadVars tv; @@ -1359,7 +1347,6 @@ static int FlagsTestParse17(void) TCPHdr tcph; memset(&tv, 0, sizeof(ThreadVars)); - memset(p, 0, SIZE_OF_PACKET); memset(&ipv4h, 0, sizeof(IPV4Hdr)); memset(&tcph, 0, sizeof(TCPHdr)); diff --git a/src/detect-xbits.c b/src/detect-xbits.c index bf2de2583b..5e63720e9d 100644 --- a/src/detect-xbits.c +++ b/src/detect-xbits.c @@ -448,7 +448,7 @@ static int XBitsTestSig01(void) "Host: one.example.org\r\n" "\r\n"; uint16_t buflen = strlen((char *)buf); - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); FAIL_IF_NULL(p); Signature *s = NULL; ThreadVars th_v; @@ -456,7 +456,6 @@ static int XBitsTestSig01(void) DetectEngineCtx *de_ctx = NULL; memset(&th_v, 0, sizeof(th_v)); - memset(p, 0, SIZE_OF_PACKET); p->src.family = AF_INET; p->dst.family = AF_INET; p->payload = buf; diff --git a/src/stream-tcp.c b/src/stream-tcp.c index 0537a741f9..15a5f3d4d6 100644 --- a/src/stream-tcp.c +++ b/src/stream-tcp.c @@ -6386,11 +6386,10 @@ const char *StreamTcpSsnStateAsString(const TcpSession *ssn) static int StreamTcpTest01 (void) { StreamTcpThread stt; - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; Flow f; - memset(p, 0, SIZE_OF_PACKET); memset (&f, 0, sizeof(Flow)); FLOW_INITIALIZE(&f); p->flow = &f; @@ -6434,7 +6433,7 @@ end: static int StreamTcpTest02 (void) { - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); FAIL_IF(unlikely(p == NULL)); Flow f; ThreadVars tv; @@ -6443,7 +6442,6 @@ static int StreamTcpTest02 (void) TCPHdr tcph; PacketQueueNoLock pq; memset(&pq,0,sizeof(pq)); - memset(p, 0, SIZE_OF_PACKET); memset (&f, 0, sizeof(Flow)); memset(&tv, 0, sizeof (ThreadVars)); memset(&stt, 0, sizeof (StreamTcpThread)); @@ -6520,14 +6518,13 @@ static int StreamTcpTest02 (void) static int StreamTcpTest03 (void) { - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; Flow f; ThreadVars tv; StreamTcpThread stt; TCPHdr tcph; - memset(p, 0, SIZE_OF_PACKET); PacketQueueNoLock pq; memset(&pq,0,sizeof(pq)); memset (&f, 0, sizeof(Flow)); @@ -6596,14 +6593,13 @@ end: static int StreamTcpTest04 (void) { - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; Flow f; ThreadVars tv; StreamTcpThread stt; TCPHdr tcph; - memset(p, 0, SIZE_OF_PACKET); PacketQueueNoLock pq; memset(&pq,0,sizeof(pq)); memset (&f, 0, sizeof(Flow)); @@ -6665,7 +6661,7 @@ end: static int StreamTcpTest05 (void) { - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; Flow f; @@ -6673,7 +6669,6 @@ static int StreamTcpTest05 (void) StreamTcpThread stt; TCPHdr tcph; uint8_t payload[4]; - memset(p, 0, SIZE_OF_PACKET); PacketQueueNoLock pq; memset(&pq,0,sizeof(PacketQueueNoLock)); memset (&f, 0, sizeof(Flow)); @@ -6765,7 +6760,7 @@ end: static int StreamTcpTest06 (void) { - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; Flow f; @@ -6773,7 +6768,6 @@ static int StreamTcpTest06 (void) ThreadVars tv; StreamTcpThread stt; TCPHdr tcph; - memset(p, 0, SIZE_OF_PACKET); PacketQueueNoLock pq; memset(&pq,0,sizeof(PacketQueueNoLock)); memset (&f, 0, sizeof(Flow)); @@ -6828,7 +6822,7 @@ end: static int StreamTcpTest07 (void) { - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); FAIL_IF(unlikely(p == NULL)); Flow f; ThreadVars tv; @@ -6837,7 +6831,6 @@ static int StreamTcpTest07 (void) uint8_t payload[1] = {0x42}; PacketQueueNoLock pq; - memset(p, 0, SIZE_OF_PACKET); memset(&pq,0,sizeof(PacketQueueNoLock)); memset (&f, 0, sizeof(Flow)); memset(&tv, 0, sizeof (ThreadVars)); @@ -6890,7 +6883,7 @@ static int StreamTcpTest07 (void) static int StreamTcpTest08 (void) { - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); FAIL_IF(unlikely(p == NULL)); Flow f; ThreadVars tv; @@ -6898,7 +6891,6 @@ static int StreamTcpTest08 (void) TCPHdr tcph; uint8_t payload[1] = {0x42}; - memset(p, 0, SIZE_OF_PACKET); PacketQueueNoLock pq; memset(&pq,0,sizeof(PacketQueueNoLock)); memset (&f, 0, sizeof(Flow)); @@ -6953,7 +6945,7 @@ static int StreamTcpTest08 (void) static int StreamTcpTest09 (void) { - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); FAIL_IF(unlikely(p == NULL)); Flow f; ThreadVars tv; @@ -6961,7 +6953,6 @@ static int StreamTcpTest09 (void) TCPHdr tcph; uint8_t payload[1] = {0x42}; - memset(p, 0, SIZE_OF_PACKET); PacketQueueNoLock pq; memset(&pq,0,sizeof(PacketQueueNoLock)); memset (&f, 0, sizeof(Flow)); @@ -7024,14 +7015,13 @@ static int StreamTcpTest09 (void) static int StreamTcpTest10 (void) { - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); FAIL_IF(unlikely(p == NULL)); Flow f; ThreadVars tv; StreamTcpThread stt; TCPHdr tcph; uint8_t payload[4]; - memset(p, 0, SIZE_OF_PACKET); PacketQueueNoLock pq; memset(&pq,0,sizeof(PacketQueueNoLock)); memset (&f, 0, sizeof(Flow)); @@ -7103,14 +7093,13 @@ static int StreamTcpTest10 (void) static int StreamTcpTest11 (void) { - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); FAIL_IF(unlikely(p == NULL)); Flow f; ThreadVars tv; StreamTcpThread stt; TCPHdr tcph; uint8_t payload[4]; - memset(p, 0, SIZE_OF_PACKET); PacketQueueNoLock pq; memset(&pq,0,sizeof(PacketQueueNoLock)); memset (&f, 0, sizeof(Flow)); @@ -7183,7 +7172,7 @@ static int StreamTcpTest11 (void) static int StreamTcpTest12 (void) { - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; Flow f; @@ -7191,7 +7180,6 @@ static int StreamTcpTest12 (void) StreamTcpThread stt; TCPHdr tcph; uint8_t payload[4]; - memset(p, 0, SIZE_OF_PACKET); PacketQueueNoLock pq; memset(&pq,0,sizeof(PacketQueueNoLock)); memset (&f, 0, sizeof(Flow)); @@ -7279,7 +7267,7 @@ end: static int StreamTcpTest13 (void) { - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; Flow f; @@ -7287,7 +7275,6 @@ static int StreamTcpTest13 (void) StreamTcpThread stt; TCPHdr tcph; uint8_t payload[4]; - memset(p, 0, SIZE_OF_PACKET); PacketQueueNoLock pq; memset(&pq,0,sizeof(PacketQueueNoLock)); memset (&f, 0, sizeof(Flow)); @@ -7479,7 +7466,7 @@ static const char *StreamTcpParseOSPolicy (char *conf_var_name) static int StreamTcpTest14 (void) { - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; Flow f; @@ -7494,7 +7481,6 @@ static int StreamTcpTest14 (void) PacketQueueNoLock pq; memset(&pq,0,sizeof(PacketQueueNoLock)); - memset(p, 0, SIZE_OF_PACKET); memset (&f, 0, sizeof(Flow)); memset(&tv, 0, sizeof (ThreadVars)); memset(&stt, 0, sizeof (StreamTcpThread)); @@ -7649,14 +7635,13 @@ end: static int StreamTcp4WHSTest01 (void) { int ret = 0; - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; Flow f; ThreadVars tv; StreamTcpThread stt; TCPHdr tcph; - memset(p, 0, SIZE_OF_PACKET); PacketQueueNoLock pq; memset(&pq,0,sizeof(PacketQueueNoLock)); memset (&f, 0, sizeof(Flow)); @@ -7731,14 +7716,13 @@ end: static int StreamTcp4WHSTest02 (void) { int ret = 0; - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; Flow f; ThreadVars tv; StreamTcpThread stt; TCPHdr tcph; - memset(p, 0, SIZE_OF_PACKET); PacketQueueNoLock pq; memset(&pq,0,sizeof(PacketQueueNoLock)); memset (&f, 0, sizeof(Flow)); @@ -7802,13 +7786,12 @@ end: static int StreamTcp4WHSTest03 (void) { int ret = 0; - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); FAIL_IF(unlikely(p == NULL)); Flow f; ThreadVars tv; StreamTcpThread stt; TCPHdr tcph; - memset(p, 0, SIZE_OF_PACKET); PacketQueueNoLock pq; memset(&pq,0,sizeof(PacketQueueNoLock)); memset (&f, 0, sizeof(Flow)); @@ -7881,7 +7864,7 @@ end: static int StreamTcpTest15 (void) { - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; Flow f; @@ -7896,7 +7879,6 @@ static int StreamTcpTest15 (void) PacketQueueNoLock pq; memset(&pq,0,sizeof(PacketQueueNoLock)); - memset(p, 0, SIZE_OF_PACKET); memset (&f, 0, sizeof(Flow)); memset(&tv, 0, sizeof (ThreadVars)); memset(&stt, 0, sizeof (StreamTcpThread)); @@ -8048,7 +8030,7 @@ end: static int StreamTcpTest16 (void) { - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; Flow f; @@ -8063,7 +8045,6 @@ static int StreamTcpTest16 (void) PacketQueueNoLock pq; memset(&pq,0,sizeof(PacketQueueNoLock)); - memset(p, 0, SIZE_OF_PACKET); memset (&f, 0, sizeof(Flow)); memset(&tv, 0, sizeof (ThreadVars)); memset(&stt, 0, sizeof (StreamTcpThread)); @@ -8218,7 +8199,7 @@ end: static int StreamTcpTest17 (void) { - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; Flow f; @@ -8233,7 +8214,6 @@ static int StreamTcpTest17 (void) PacketQueueNoLock pq; memset(&pq,0,sizeof(PacketQueueNoLock)); - memset(p, 0, SIZE_OF_PACKET); memset (&f, 0, sizeof(Flow)); memset(&tv, 0, sizeof (ThreadVars)); memset(&stt, 0, sizeof (StreamTcpThread)); @@ -8387,7 +8367,7 @@ static int StreamTcpTest18 (void) char os_policy_name[10] = "windows"; const char *ip_addr; TcpStream stream; - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; IPV4Hdr ipv4h; @@ -8395,7 +8375,6 @@ static int StreamTcpTest18 (void) memset(&addr, 0, sizeof(addr)); memset(&stream, 0, sizeof(stream)); - memset(p, 0, SIZE_OF_PACKET); memset(&ipv4h, 0, sizeof(ipv4h)); StreamTcpUTInit(&stt.ra_ctx); @@ -8436,7 +8415,7 @@ static int StreamTcpTest19 (void) char os_policy_name[10] = "windows"; const char *ip_addr; TcpStream stream; - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; IPV4Hdr ipv4h; @@ -8444,7 +8423,6 @@ static int StreamTcpTest19 (void) memset(&addr, 0, sizeof(addr)); memset(&stream, 0, sizeof(stream)); - memset(p, 0, SIZE_OF_PACKET); memset(&ipv4h, 0, sizeof(ipv4h)); StreamTcpUTInit(&stt.ra_ctx); @@ -8488,7 +8466,7 @@ static int StreamTcpTest20 (void) char os_policy_name[10] = "linux"; const char *ip_addr; TcpStream stream; - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; IPV4Hdr ipv4h; @@ -8496,7 +8474,6 @@ static int StreamTcpTest20 (void) memset(&addr, 0, sizeof(addr)); memset(&stream, 0, sizeof(stream)); - memset(p, 0, SIZE_OF_PACKET); memset(&ipv4h, 0, sizeof(ipv4h)); StreamTcpUTInit(&stt.ra_ctx); @@ -8540,7 +8517,7 @@ static int StreamTcpTest21 (void) char os_policy_name[10] = "linux"; const char *ip_addr; TcpStream stream; - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; IPV4Hdr ipv4h; @@ -8548,7 +8525,6 @@ static int StreamTcpTest21 (void) memset(&addr, 0, sizeof(addr)); memset(&stream, 0, sizeof(stream)); - memset(p, 0, SIZE_OF_PACKET); memset(&ipv4h, 0, sizeof(ipv4h)); StreamTcpUTInit(&stt.ra_ctx); @@ -8592,7 +8568,7 @@ static int StreamTcpTest22 (void) char os_policy_name[10] = "windows"; const char *ip_addr; TcpStream stream; - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; IPV4Hdr ipv4h; @@ -8600,7 +8576,6 @@ static int StreamTcpTest22 (void) memset(&addr, 0, sizeof(addr)); memset(&stream, 0, sizeof(stream)); - memset(p, 0, SIZE_OF_PACKET); memset(&ipv4h, 0, sizeof(ipv4h)); StreamTcpUTInit(&stt.ra_ctx); @@ -8647,11 +8622,10 @@ static int StreamTcpTest23(void) ThreadVars tv; PacketQueueNoLock pq; - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); FAIL_IF(p == NULL); memset(&pq,0,sizeof(PacketQueueNoLock)); - memset(p, 0, SIZE_OF_PACKET); memset(&f, 0, sizeof (Flow)); memset(&tcph, 0, sizeof (TCPHdr)); memset(&tv, 0, sizeof (ThreadVars)); @@ -8707,7 +8681,7 @@ static int StreamTcpTest24(void) { StreamTcpThread stt; TcpSession ssn; - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); FAIL_IF (p == NULL); Flow f; TCPHdr tcph; @@ -8720,7 +8694,6 @@ static int StreamTcpTest24(void) StreamTcpUTInit(&stt.ra_ctx); StreamTcpUTSetupSession(&ssn); - memset(p, 0, SIZE_OF_PACKET); memset(&f, 0, sizeof (Flow)); memset(&tcph, 0, sizeof (TCPHdr)); FLOW_INITIALIZE(&f); @@ -8775,7 +8748,7 @@ static int StreamTcpTest24(void) */ static int StreamTcpTest25(void) { - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; Flow f; @@ -8787,7 +8760,6 @@ static int StreamTcpTest25(void) PacketQueueNoLock pq; memset(&pq,0,sizeof(PacketQueueNoLock)); - memset(p, 0, SIZE_OF_PACKET); memset (&f, 0, sizeof(Flow)); memset(&tv, 0, sizeof (ThreadVars)); memset(&stt, 0, sizeof (StreamTcpThread)); @@ -8868,7 +8840,7 @@ end: */ static int StreamTcpTest26(void) { - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; Flow f; @@ -8880,7 +8852,6 @@ static int StreamTcpTest26(void) PacketQueueNoLock pq; memset(&pq,0,sizeof(PacketQueueNoLock)); - memset(p, 0, SIZE_OF_PACKET); memset (&f, 0, sizeof(Flow)); memset(&tv, 0, sizeof (ThreadVars)); memset(&stt, 0, sizeof (StreamTcpThread)); @@ -8962,7 +8933,7 @@ end: */ static int StreamTcpTest27(void) { - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; Flow f; @@ -8974,7 +8945,6 @@ static int StreamTcpTest27(void) PacketQueueNoLock pq; memset(&pq,0,sizeof(PacketQueueNoLock)); - memset(p, 0, SIZE_OF_PACKET); memset (&f, 0, sizeof(Flow)); memset(&tv, 0, sizeof (ThreadVars)); memset(&stt, 0, sizeof (StreamTcpThread)); @@ -9933,7 +9903,7 @@ end: */ static int StreamTcpTest37(void) { - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; Flow f; @@ -9945,7 +9915,6 @@ static int StreamTcpTest37(void) PacketQueueNoLock pq; memset(&pq,0,sizeof(PacketQueueNoLock)); - memset(p, 0, SIZE_OF_PACKET); memset (&f, 0, sizeof(Flow)); memset(&tv, 0, sizeof (ThreadVars)); memset(&stt, 0, sizeof (StreamTcpThread)); @@ -10066,10 +10035,9 @@ static int StreamTcpTest38 (void) memset(&tcph, 0, sizeof (TCPHdr)); memset(&pq,0,sizeof(PacketQueueNoLock)); - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; - memset(p, 0, SIZE_OF_PACKET); FLOW_INITIALIZE(&f); p->flow = &f; @@ -10221,10 +10189,9 @@ static int StreamTcpTest39 (void) memset(&tcph, 0, sizeof (TCPHdr)); memset(&pq,0,sizeof(PacketQueueNoLock)); - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; - memset(p, 0, SIZE_OF_PACKET); FLOW_INITIALIZE(&f); p->flow = &f; @@ -10343,12 +10310,11 @@ static int StreamTcpTest42 (void) StreamTcpThread stt; TCPHdr tcph; PacketQueueNoLock pq; - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); TcpSession *ssn; if (unlikely(p == NULL)) return 0; - memset(p, 0, SIZE_OF_PACKET); memset(&pq,0,sizeof(PacketQueueNoLock)); memset (&f, 0, sizeof(Flow)); @@ -10435,12 +10401,11 @@ static int StreamTcpTest43 (void) StreamTcpThread stt; TCPHdr tcph; PacketQueueNoLock pq; - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); TcpSession *ssn; if (unlikely(p == NULL)) return 0; - memset(p, 0, SIZE_OF_PACKET); memset(&pq,0,sizeof(PacketQueueNoLock)); memset (&f, 0, sizeof(Flow)); @@ -10527,12 +10492,11 @@ static int StreamTcpTest44 (void) StreamTcpThread stt; TCPHdr tcph; PacketQueueNoLock pq; - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); TcpSession *ssn; if (unlikely(p == NULL)) return 0; - memset(p, 0, SIZE_OF_PACKET); memset(&pq,0,sizeof(PacketQueueNoLock)); memset (&f, 0, sizeof(Flow)); @@ -10614,12 +10578,11 @@ static int StreamTcpTest45 (void) StreamTcpThread stt; TCPHdr tcph; PacketQueueNoLock pq; - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); TcpSession *ssn; if (unlikely(p == NULL)) return 0; - memset(p, 0, SIZE_OF_PACKET); memset(&pq,0,sizeof(PacketQueueNoLock)); memset (&f, 0, sizeof(Flow)); diff --git a/src/tests/detect.c b/src/tests/detect.c index 34b18cd828..b1eb012b2c 100644 --- a/src/tests/detect.c +++ b/src/tests/detect.c @@ -943,7 +943,7 @@ static int SigTest15 (void) uint8_t *buf = (uint8_t *) "CONNECT 213.92.8.7:31204 HTTP/1.1"; uint16_t buflen = strlen((char *)buf); - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; ThreadVars th_v; @@ -951,7 +951,6 @@ static int SigTest15 (void) int result = 0; memset(&th_v, 0, sizeof(th_v)); - memset(p, 0, SIZE_OF_PACKET); p->src.family = AF_INET; p->dst.family = AF_INET; p->payload = buf; @@ -1102,7 +1101,7 @@ static int SigTest18 (void) uint8_t *buf = (uint8_t *) "220 (vsFTPd 2.0.5)\r\n"; uint16_t buflen = strlen((char *)buf); - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; ThreadVars th_v; @@ -1110,7 +1109,6 @@ static int SigTest18 (void) int result = 0; memset(&th_v, 0, sizeof(th_v)); - memset(p, 0, SIZE_OF_PACKET); p->src.family = AF_INET; p->dst.family = AF_INET; p->payload = buf; @@ -1155,7 +1153,7 @@ static int SigTest19 (void) uint8_t *buf = (uint8_t *) "220 (vsFTPd 2.0.5)\r\n"; uint16_t buflen = strlen((char *)buf); - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; ThreadVars th_v; @@ -1163,7 +1161,6 @@ static int SigTest19 (void) int result = 0; memset(&th_v, 0, sizeof(th_v)); - memset(p, 0, SIZE_OF_PACKET); p->src.family = AF_INET; p->src.addr_data32[0] = UTHSetIPv4Address("192.168.0.1"); p->dst.addr_data32[0] = UTHSetIPv4Address("1.2.3.4"); @@ -1216,7 +1213,7 @@ static int SigTest20 (void) uint8_t *buf = (uint8_t *) "220 (vsFTPd 2.0.5)\r\n"; uint16_t buflen = strlen((char *)buf); - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; ThreadVars th_v; @@ -1224,7 +1221,6 @@ static int SigTest20 (void) int result = 0; memset(&th_v, 0, sizeof(th_v)); - memset(p, 0, SIZE_OF_PACKET); p->src.family = AF_INET; p->src.addr_data32[0] = UTHSetIPv4Address("192.168.0.1"); p->dst.addr_data32[0] = UTHSetIPv4Address("1.2.3.4"); @@ -1513,10 +1509,10 @@ static int SigTest24IPV4Keyword(void) 0x40, 0x01, 0xb7, 0x52, 0xc0, 0xa8, 0x01, 0x03, 0xc0, 0xa8, 0x01, 0x06}; - Packet *p1 = SCMalloc(SIZE_OF_PACKET); + Packet *p1 = PacketGetFromAlloc(); if (unlikely(p1 == NULL)) return 0; - Packet *p2 = SCMalloc(SIZE_OF_PACKET); + Packet *p2 = PacketGetFromAlloc(); if (unlikely(p2 == NULL)) { SCFree(p1); return 0; @@ -1530,8 +1526,6 @@ static int SigTest24IPV4Keyword(void) uint16_t buflen = strlen((char *)buf); memset(&th_v, 0, sizeof(ThreadVars)); - memset(p1, 0, SIZE_OF_PACKET); - memset(p2, 0, SIZE_OF_PACKET); PACKET_RESET_CHECKSUMS(p1); PACKET_RESET_CHECKSUMS(p2); @@ -1617,10 +1611,10 @@ static int SigTest25NegativeIPV4Keyword(void) 0x40, 0x01, 0xb7, 0x52, 0xc0, 0xa8, 0x01, 0x03, 0xc0, 0xa8, 0x01, 0x06}; - Packet *p1 = SCMalloc(SIZE_OF_PACKET); + Packet *p1 = PacketGetFromAlloc(); if (unlikely(p1 == NULL)) return 0; - Packet *p2 = SCMalloc(SIZE_OF_PACKET); + Packet *p2 = PacketGetFromAlloc(); if (unlikely(p2 == NULL)) { SCFree(p1); return 0; @@ -1634,8 +1628,6 @@ static int SigTest25NegativeIPV4Keyword(void) uint16_t buflen = strlen((char *)buf); memset(&th_v, 0, sizeof(ThreadVars)); - memset(p1, 0, SIZE_OF_PACKET); - memset(p2, 0, SIZE_OF_PACKET); PACKET_RESET_CHECKSUMS(p1); PACKET_RESET_CHECKSUMS(p2); @@ -1727,11 +1719,11 @@ static int SigTest26TCPV4Keyword(void) 0x04, 0x02, 0x08, 0x0a, 0x6e, 0x18, 0x78, 0x73, 0x01, 0x71, 0x74, 0xde, 0x01, 0x03, 0x03, 0x03}; - Packet *p1 = SCMalloc(SIZE_OF_PACKET); + Packet *p1 = PacketGetFromAlloc(); if (unlikely(p1 == NULL)) return 0; - Packet *p2 = SCMalloc(SIZE_OF_PACKET); + Packet *p2 = PacketGetFromAlloc(); if (unlikely(p2 == NULL)) { SCFree(p1); return 0; @@ -1741,8 +1733,6 @@ static int SigTest26TCPV4Keyword(void) DetectEngineThreadCtx *det_ctx = NULL; memset(&th_v, 0, sizeof(ThreadVars)); - memset(p1, 0, SIZE_OF_PACKET); - memset(p2, 0, SIZE_OF_PACKET); PacketCopyData(p1, raw_ipv4, sizeof(raw_ipv4)); PacketCopyDataOffset(p1, GET_PKT_LEN(p1), valid_raw_tcp, sizeof(valid_raw_tcp)); @@ -1826,11 +1816,11 @@ static int SigTest26TCPV4AndNegativeIPV4Keyword(void) 0x04, 0x02, 0x08, 0x0a, 0x6e, 0x18, 0x78, 0x73, 0x01, 0x71, 0x74, 0xde, 0x01, 0x03, 0x03, 0x03}; - Packet *p1 = SCMalloc(SIZE_OF_PACKET); + Packet *p1 = PacketGetFromAlloc(); if (unlikely(p1 == NULL)) return 0; - Packet *p2 = SCMalloc(SIZE_OF_PACKET); + Packet *p2 = PacketGetFromAlloc(); if (unlikely(p2 == NULL)) { SCFree(p1); return 0; @@ -1841,8 +1831,6 @@ static int SigTest26TCPV4AndNegativeIPV4Keyword(void) int result = 0; memset(&th_v, 0, sizeof(ThreadVars)); - memset(p1, 0, SIZE_OF_PACKET); - memset(p2, 0, SIZE_OF_PACKET); PacketCopyData(p1, raw_ipv4, sizeof(raw_ipv4)); PacketCopyDataOffset(p1, GET_PKT_LEN(p1), valid_raw_tcp, sizeof(valid_raw_tcp)); @@ -1952,11 +1940,11 @@ static int SigTest26TCPV4AndIPV4Keyword(void) 0x19, 0x69, 0x81, 0x7e, 0xFF, 0xAA, 0x00, 0x00, 0x04, 0x02, 0x00, 0x00}; - Packet *p1 = SCMalloc(SIZE_OF_PACKET); + Packet *p1 = PacketGetFromAlloc(); if (unlikely(p1 == NULL)) return 0; - Packet *p2 = SCMalloc(SIZE_OF_PACKET); + Packet *p2 = PacketGetFromAlloc(); if (unlikely(p2 == NULL)) { SCFree(p1); return 0; @@ -1967,8 +1955,6 @@ static int SigTest26TCPV4AndIPV4Keyword(void) int result = 0; memset(&th_v, 0, sizeof(ThreadVars)); - memset(p1, 0, SIZE_OF_PACKET); - memset(p2, 0, SIZE_OF_PACKET); PacketCopyData(p1, raw_ipv4, sizeof(raw_ipv4)); PacketCopyDataOffset(p1, GET_PKT_LEN(p1), valid_raw_tcp, sizeof(valid_raw_tcp)); @@ -2067,11 +2053,10 @@ static int SigTest27NegativeTCPV4Keyword(void) 0x04, 0x02, 0x08, 0x0a, 0x6e, 0x18, 0x78, 0x73, 0x01, 0x71, 0x74, 0xde, 0x01, 0x03, 0x03, 0x03}; - - Packet *p1 = SCMalloc(SIZE_OF_PACKET); + Packet *p1 = PacketGetFromAlloc(); if (unlikely(p1 == NULL)) return 0; - Packet *p2 = SCMalloc(SIZE_OF_PACKET); + Packet *p2 = PacketGetFromAlloc(); if (unlikely(p2 == NULL)) { SCFree(p1); return 0; @@ -2081,8 +2066,6 @@ static int SigTest27NegativeTCPV4Keyword(void) int result = 0; memset(&th_v, 0, sizeof(ThreadVars)); - memset(p1, 0, SIZE_OF_PACKET); - memset(p2, 0, SIZE_OF_PACKET); PacketCopyData(p1, raw_ipv4, sizeof(raw_ipv4)); PacketCopyDataOffset(p1, GET_PKT_LEN(p1), valid_raw_tcp, sizeof(valid_raw_tcp)); @@ -2194,10 +2177,10 @@ static int SigTest28TCPV6Keyword(void) 0x01, 0x01, 0x08, 0x0a, 0x00, 0x08, 0xca, 0x5a, 0x00, 0x01, 0x69, 0x28}; - Packet *p1 = SCMalloc(SIZE_OF_PACKET); + Packet *p1 = PacketGetFromAlloc(); if (unlikely(p1 == NULL)) return 0; - Packet *p2 = SCMalloc(SIZE_OF_PACKET); + Packet *p2 = PacketGetFromAlloc(); if (unlikely(p2 == NULL)) { SCFree(p1); return 0; @@ -2207,8 +2190,6 @@ static int SigTest28TCPV6Keyword(void) int result = 0; memset(&th_v, 0, sizeof(ThreadVars)); - memset(p1, 0, SIZE_OF_PACKET); - memset(p2, 0, SIZE_OF_PACKET); PACKET_RESET_CHECKSUMS(p1); p1->ip6h = (IPV6Hdr *)(valid_raw_ipv6 + 14); @@ -2322,10 +2303,10 @@ static int SigTest29NegativeTCPV6Keyword(void) 0x01, 0x01, 0x08, 0x0a, 0x00, 0x08, 0xca, 0x5a, 0x00, 0x01, 0x69, 0x28}; - Packet *p1 = SCMalloc(SIZE_OF_PACKET); + Packet *p1 = PacketGetFromAlloc(); if (unlikely(p1 == NULL)) return 0; - Packet *p2 = SCMalloc(SIZE_OF_PACKET); + Packet *p2 = PacketGetFromAlloc(); if (unlikely(p2 == NULL)) { SCFree(p1); return 0; @@ -2335,8 +2316,6 @@ static int SigTest29NegativeTCPV6Keyword(void) int result = 0; memset(&th_v, 0, sizeof(ThreadVars)); - memset(p1, 0, SIZE_OF_PACKET); - memset(p2, 0, SIZE_OF_PACKET); PACKET_RESET_CHECKSUMS(p1); p1->ip6h = (IPV6Hdr *)(valid_raw_ipv6 + 14); @@ -2445,9 +2424,9 @@ static int SigTest30UDPV4Keyword(void) 0x61, 0x64, 0x01, 0x6c, 0x06, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0xc0, 0x27}; - Packet *p1 = SCMalloc(SIZE_OF_PACKET); + Packet *p1 = PacketGetFromAlloc(); FAIL_IF_NULL(p1); - Packet *p2 = SCMalloc(SIZE_OF_PACKET); + Packet *p2 = PacketGetFromAlloc(); FAIL_IF_NULL(p2); ThreadVars th_v; @@ -2457,8 +2436,6 @@ static int SigTest30UDPV4Keyword(void) "\r\n\r\nyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy"; memset(&th_v, 0, sizeof(ThreadVars)); - memset(p1, 0, SIZE_OF_PACKET); - memset(p2, 0, SIZE_OF_PACKET); PACKET_RESET_CHECKSUMS(p1); p1->ip4h = (IPV4Hdr *)raw_ipv4; @@ -2549,10 +2526,10 @@ static int SigTest31NegativeUDPV4Keyword(void) 0x61, 0x64, 0x01, 0x6c, 0x06, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0xc0, 0x27}; - Packet *p1 = SCMalloc(SIZE_OF_PACKET); + Packet *p1 = PacketGetFromAlloc(); if (unlikely(p1 == NULL)) return 0; - Packet *p2 = SCMalloc(SIZE_OF_PACKET); + Packet *p2 = PacketGetFromAlloc(); if (unlikely(p2 == NULL)) { SCFree(p1); return 0; @@ -2565,8 +2542,6 @@ static int SigTest31NegativeUDPV4Keyword(void) "\r\n\r\nyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy"; memset(&th_v, 0, sizeof(ThreadVars)); - memset(p1, 0, SIZE_OF_PACKET); - memset(p2, 0, SIZE_OF_PACKET); PACKET_RESET_CHECKSUMS(p1); p1->ip4h = (IPV4Hdr *)raw_ipv4; @@ -2666,9 +2641,9 @@ static int SigTest32UDPV6Keyword(void) 0x00, 0x00, 0xf9, 0xc8, 0xe7, 0x36, 0x57, 0xb0, 0x09, 0x01}; - Packet *p1 = SCMalloc(SIZE_OF_PACKET); + Packet *p1 = PacketGetFromAlloc(); FAIL_IF_NULL(p1); - Packet *p2 = SCMalloc(SIZE_OF_PACKET); + Packet *p2 = PacketGetFromAlloc(); FAIL_IF_NULL(p2); ThreadVars th_v; @@ -2678,8 +2653,6 @@ static int SigTest32UDPV6Keyword(void) "\r\n\r\n"; memset(&th_v, 0, sizeof(ThreadVars)); - memset(p1, 0, SIZE_OF_PACKET); - memset(p2, 0, SIZE_OF_PACKET); PACKET_RESET_CHECKSUMS(p1); p1->ip6h = (IPV6Hdr *)(valid_raw_ipv6 + 14); @@ -2763,10 +2736,10 @@ static int SigTest33NegativeUDPV6Keyword(void) 0x00, 0x00, 0xf9, 0xc8, 0xe7, 0x36, 0x57, 0xb0, 0x09, 0x01}; - Packet *p1 = SCMalloc(SIZE_OF_PACKET); + Packet *p1 = PacketGetFromAlloc(); if (unlikely(p1 == NULL)) return 0; - Packet *p2 = SCMalloc(SIZE_OF_PACKET); + Packet *p2 = PacketGetFromAlloc(); if (unlikely(p2 == NULL)) { SCFree(p1); return 0; @@ -2779,8 +2752,6 @@ static int SigTest33NegativeUDPV6Keyword(void) "\r\n\r\n"; memset(&th_v, 0, sizeof(ThreadVars)); - memset(p1, 0, SIZE_OF_PACKET); - memset(p2, 0, SIZE_OF_PACKET); PACKET_RESET_CHECKSUMS(p1); p1->ip6h = (IPV6Hdr *)(valid_raw_ipv6 + 14); @@ -2880,10 +2851,10 @@ static int SigTest34ICMPV4Keyword(void) 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x38}; - Packet *p1 = SCMalloc(SIZE_OF_PACKET); + Packet *p1 = PacketGetFromAlloc(); if (unlikely(p1 == NULL)) return 0; - Packet *p2 = SCMalloc(SIZE_OF_PACKET); + Packet *p2 = PacketGetFromAlloc(); if (unlikely(p2 == NULL)) { SCFree(p1); return 0; @@ -2897,8 +2868,6 @@ static int SigTest34ICMPV4Keyword(void) uint16_t buflen = strlen((char *)buf); memset(&th_v, 0, sizeof(ThreadVars)); - memset(p1, 0, SIZE_OF_PACKET); - memset(p2, 0, SIZE_OF_PACKET); PACKET_RESET_CHECKSUMS(p1); p1->ip4h = (IPV4Hdr *)(valid_raw_ipv4); @@ -3000,10 +2969,10 @@ static int SigTest35NegativeICMPV4Keyword(void) 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x38}; - Packet *p1 = SCMalloc(SIZE_OF_PACKET); + Packet *p1 = PacketGetFromAlloc(); if (unlikely(p1 == NULL)) return 0; - Packet *p2 = SCMalloc(SIZE_OF_PACKET); + Packet *p2 = PacketGetFromAlloc(); if (unlikely(p2 == NULL)) { SCFree(p1); return 0; @@ -3017,8 +2986,6 @@ static int SigTest35NegativeICMPV4Keyword(void) uint16_t buflen = strlen((char *)buf); memset(&th_v, 0, sizeof(ThreadVars)); - memset(p1, 0, SIZE_OF_PACKET); - memset(p2, 0, SIZE_OF_PACKET); PACKET_RESET_CHECKSUMS(p1); p1->ip4h = (IPV4Hdr *)(valid_raw_ipv4); @@ -3095,7 +3062,7 @@ end: static int SigTest38(void) { - Packet *p1 = SCMalloc(SIZE_OF_PACKET); + Packet *p1 = PacketGetFromAlloc(); if (unlikely(p1 == NULL)) return 0; ThreadVars th_v; @@ -3136,7 +3103,6 @@ static int SigTest38(void) uint16_t buflen = sizeof(buf); memset(&th_v, 0, sizeof(ThreadVars)); - memset(p1, 0, SIZE_OF_PACKET); /* Copy raw data into packet */ if (PacketCopyData(p1, raw_eth, ethlen) == -1) { @@ -3226,7 +3192,7 @@ end: static int SigTest39(void) { - Packet *p1 = SCMalloc(SIZE_OF_PACKET); + Packet *p1 = PacketGetFromAlloc(); if (unlikely(p1 == NULL)) return 0; ThreadVars th_v; @@ -3267,7 +3233,6 @@ static int SigTest39(void) uint16_t buflen = sizeof(buf); memset(&th_v, 0, sizeof(ThreadVars)); - memset(p1, 0, SIZE_OF_PACKET); /* Copy raw data into packet */ if (PacketCopyData(p1, raw_eth, ethlen) == -1) { @@ -3402,7 +3367,7 @@ static int SigTest36ContentAndIsdataatKeywords01 (void) ,0x65,0x72,0x65,0x3c,0x2f,0x41,0x3e,0x2e,0x0d,0x0a,0x3c,0x2f,0x42,0x4f,0x44,0x59 ,0x3e,0x3c,0x2f,0x48,0x54,0x4d,0x4c,0x3e,0x0d,0x0a }; - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; DecodeThreadVars dtv; @@ -3410,7 +3375,6 @@ static int SigTest36ContentAndIsdataatKeywords01 (void) ThreadVars th_v; DetectEngineThreadCtx *det_ctx = NULL; - memset(p, 0, SIZE_OF_PACKET); memset(&dtv, 0, sizeof(DecodeThreadVars)); memset(&th_v, 0, sizeof(th_v)); @@ -3521,7 +3485,7 @@ static int SigTest37ContentAndIsdataatKeywords02 (void) ,0x65,0x72,0x65,0x3c,0x2f,0x41,0x3e,0x2e,0x0d,0x0a,0x3c,0x2f,0x42,0x4f,0x44,0x59 ,0x3e,0x3c,0x2f,0x48,0x54,0x4d,0x4c,0x3e,0x0d,0x0a }; - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; DecodeThreadVars dtv; @@ -3529,7 +3493,6 @@ static int SigTest37ContentAndIsdataatKeywords02 (void) ThreadVars th_v; DetectEngineThreadCtx *det_ctx = NULL; - memset(p, 0, SIZE_OF_PACKET); memset(&dtv, 0, sizeof(DecodeThreadVars)); memset(&th_v, 0, sizeof(th_v)); @@ -3612,7 +3575,7 @@ static int SigTest40NoPacketInspection01(void) uint8_t *buf = (uint8_t *) "220 (vsFTPd 2.0.5)\r\n"; uint16_t buflen = strlen((char *)buf); - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); TCPHdr tcphdr; if (unlikely(p == NULL)) return 0; @@ -3623,7 +3586,6 @@ static int SigTest40NoPacketInspection01(void) int result = 0; memset(&th_v, 0, sizeof(th_v)); - memset(p, 0, SIZE_OF_PACKET); memset(&pq, 0, sizeof(pq)); memset(&f, 0, sizeof(f)); memset(&tcphdr, 0, sizeof(tcphdr)); @@ -3691,9 +3653,8 @@ static int SigTest40NoPayloadInspection02(void) ThreadVars th_v; memset(&th_v, 0, sizeof(th_v)); - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); FAIL_IF_NULL(p); - memset(p, 0, SIZE_OF_PACKET); p->src.family = AF_INET; p->dst.family = AF_INET; @@ -3734,7 +3695,7 @@ static int SigTestMemory01 (void) "Host: two.example.org\r\n" "\r\n\r\n"; uint16_t buflen = strlen((char *)buf); - Packet *p = SCMalloc(SIZE_OF_PACKET); + Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; ThreadVars th_v; @@ -3742,7 +3703,6 @@ static int SigTestMemory01 (void) int result = 0; memset(&th_v, 0, sizeof(th_v)); - memset(p, 0, SIZE_OF_PACKET); p->src.family = AF_INET; p->dst.family = AF_INET; p->payload = buf; @@ -4276,10 +4236,9 @@ static int SigTestWithin01 (void) DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx); /* packet 1 */ - p1 = SCMalloc(SIZE_OF_PACKET); + p1 = PacketGetFromAlloc(); if (unlikely(p1 == NULL)) return 0; - memset(p1, 0, SIZE_OF_PACKET); DecodeEthernet(&th_v, &dtv, p1, rawpkt1, sizeof(rawpkt1)); SigMatchSignatures(&th_v, de_ctx, det_ctx, p1); if (!(PacketAlertCheck(p1, 556))) { @@ -4288,10 +4247,9 @@ static int SigTestWithin01 (void) } /* packet 2 */ - p2 = SCMalloc(SIZE_OF_PACKET); + p2 = PacketGetFromAlloc(); if (unlikely(p2 == NULL)) return 0; - memset(p2, 0, SIZE_OF_PACKET); DecodeEthernet(&th_v, &dtv, p2, rawpkt2, sizeof(rawpkt2)); SigMatchSignatures(&th_v, de_ctx, det_ctx, p2); if (!(PacketAlertCheck(p2, 556))) { @@ -4300,10 +4258,9 @@ static int SigTestWithin01 (void) } /* packet 3 */ - p3 = SCMalloc(SIZE_OF_PACKET); + p3 = PacketGetFromAlloc(); if (unlikely(p3 == NULL)) return 0; - memset(p3, 0, SIZE_OF_PACKET); DecodeEthernet(&th_v, &dtv, p3, rawpkt3, sizeof(rawpkt3)); SigMatchSignatures(&th_v, de_ctx, det_ctx, p3); if (!(PacketAlertCheck(p3, 556))) { @@ -4312,10 +4269,9 @@ static int SigTestWithin01 (void) } /* packet 4 */ - p4 = SCMalloc(SIZE_OF_PACKET); + p4 = PacketGetFromAlloc(); if (unlikely(p4 == NULL)) return 0; - memset(p4, 0, SIZE_OF_PACKET); DecodeEthernet(&th_v, &dtv, p4, rawpkt4, sizeof(rawpkt4)); SigMatchSignatures(&th_v, de_ctx, det_ctx, p4); if (!(PacketAlertCheck(p4, 556))) {