Fix a number of unittests not properly initializing a packet causing issues on some archs.

remotes/origin/master-1.1.x
Victor Julien 15 years ago
parent 43b2e63c1e
commit 4025567a5a

@ -30,7 +30,7 @@
#include "detect.h"
#include "flow.h"
#include "conf.h"
#include "pkt-var.h"
#include "threads.h"
#include "threadvars.h"
#include "tm-modules.h"
@ -997,6 +997,8 @@ static int Unified2Test01 (void) {
p->pkt = (uint8_t *)(p + 1);
memset(&s, 0, sizeof(Signature));
PACKET_INITIALIZE(p);
p->alerts.cnt++;
p->alerts.alerts[p->alerts.cnt-1].s = &s;
p->alerts.alerts[p->alerts.cnt-1].s->id = 1;
@ -1038,6 +1040,7 @@ static int Unified2Test01 (void) {
Unified2AlertDeInitCtx(oc);
PACKET_CLEANUP(p);
SCFree(p);
return 1;
}
@ -1083,6 +1086,8 @@ static int Unified2Test02 (void) {
p->pkt = (uint8_t *)(p + 1);
memset(&s, 0, sizeof(Signature));
PACKET_INITIALIZE(p);
p->alerts.cnt++;
p->alerts.alerts[p->alerts.cnt-1].s = &s;
p->alerts.alerts[p->alerts.cnt-1].s->id = 1;
@ -1124,6 +1129,7 @@ static int Unified2Test02 (void) {
Unified2AlertDeInitCtx(oc);
PACKET_CLEANUP(p);
SCFree(p);
return 1;
}
@ -1175,6 +1181,8 @@ static int Unified2Test03 (void) {
p->pkt = (uint8_t *)(p + 1);
memset(&s, 0, sizeof(Signature));
PACKET_INITIALIZE(p);
p->alerts.cnt++;
p->alerts.alerts[p->alerts.cnt-1].s = &s;
p->alerts.alerts[p->alerts.cnt-1].s->id = 1;
@ -1222,6 +1230,7 @@ static int Unified2Test03 (void) {
pkt = PacketDequeue(&pq);
}
PACKET_CLEANUP(p);
SCFree(p);
return 1;
}
@ -1261,6 +1270,8 @@ static int Unified2Test04 (void) {
p->pkt = (uint8_t *)(p + 1);
memset(&s, 0, sizeof(Signature));
PACKET_INITIALIZE(p);
p->alerts.cnt++;
p->alerts.alerts[p->alerts.cnt-1].s = &s;
p->alerts.alerts[p->alerts.cnt-1].s->id = 1;
@ -1302,6 +1313,7 @@ static int Unified2Test04 (void) {
Unified2AlertDeInitCtx(oc);
PACKET_CLEANUP(p);
SCFree(p);
return 1;
}
@ -1345,6 +1357,8 @@ static int Unified2Test05 (void) {
p->pkt = (uint8_t *)(p + 1);
memset(&s, 0, sizeof(Signature));
PACKET_INITIALIZE(p);
p->alerts.cnt++;
p->alerts.alerts[p->alerts.cnt-1].s = &s;
p->alerts.alerts[p->alerts.cnt-1].s->id = 1;
@ -1388,6 +1402,7 @@ static int Unified2Test05 (void) {
Unified2AlertDeInitCtx(oc);
PACKET_CLEANUP(p);
SCFree(p);
return 1;
}

@ -1545,6 +1545,7 @@ int DecodeIPV4DefragTest01(void)
memset(&pq, 0, sizeof(PacketQueue));
memset(p, 0, sizeof(Packet));
PACKET_INITIALIZE(p);
FlowInitConfig(FLOW_QUIET);
p->pkt = pkt1;
@ -1612,10 +1613,12 @@ int DecodeIPV4DefragTest01(void)
}
}
PACKET_CLEANUP(p);
SCFree(tp);
end:
end:
FlowShutdown();
PACKET_CLEANUP(p);
SCFree(p);
return result;
}
@ -1685,6 +1688,7 @@ int DecodeIPV4DefragTest02(void)
memset(&pq, 0, sizeof(PacketQueue));
memset(p, 0, sizeof(Packet));
PACKET_INITIALIZE(p);
FlowInitConfig(FLOW_QUIET);
p->pkt = pkt1;
@ -1753,10 +1757,12 @@ int DecodeIPV4DefragTest02(void)
}
}
PACKET_CLEANUP(p);
SCFree(tp);
end:
end:
FlowShutdown();
PACKET_CLEANUP(p);
SCFree(p);
return result;
}
@ -1822,6 +1828,7 @@ int DecodeIPV4DefragTest03(void)
memset(&pq, 0, sizeof(PacketQueue));
memset(p, 0, sizeof(Packet));
PACKET_INITIALIZE(p);
FlowInitConfig(FLOW_QUIET);
p->pkt = pkt;
@ -1915,10 +1922,12 @@ int DecodeIPV4DefragTest03(void)
}
}
PACKET_CLEANUP(p);
SCFree(tp);
end:
end:
FlowShutdown();
PACKET_CLEANUP(p);
SCFree(p);
return result;
}

@ -1273,7 +1273,11 @@ BuildTestPacket(uint16_t id, uint16_t off, int mf, const char content,
p = SCCalloc(1, sizeof(*p) + default_packet_size);
if (p == NULL)
return NULL;
PACKET_INITIALIZE(p);
p->pkt = ((uint8_t *)p) + sizeof(*p);
gettimeofday(&p->ts, NULL);
//p->ip4h = (IPV4Hdr *)GET_PKT_DATA(p);
ip4h.ip_verhl = 4 << 4;
@ -1343,6 +1347,9 @@ IPV6BuildTestPacket(uint32_t id, uint16_t off, int mf, const char content,
p = SCCalloc(1, sizeof(*p) + default_packet_size);
if (p == NULL)
return NULL;
PACKET_INITIALIZE(p);
p->pkt = ((uint8_t *)p) + sizeof(*p);
gettimeofday(&p->ts, NULL);

@ -56,6 +56,8 @@
#include "stream-tcp-util.h"
#include "stream.h"
#include "pkt-var.h"
#include "app-layer-parser.h"
#include "app-layer-protos.h"
@ -8670,6 +8672,8 @@ static int StreamTcpTest40(void) {
memset(&tv, 0, sizeof(ThreadVars));
memset(p, 0, SIZE_OF_PACKET);
PACKET_INITIALIZE(p);
p->pkt = (uint8_t *)(p + 1);
SET_PKT_LEN(p, sizeof(raw_vlan));
memcpy(GET_PKT_DATA(p), raw_vlan, sizeof(raw_vlan));
@ -8702,6 +8706,7 @@ static int StreamTcpTest40(void) {
}
FlowShutdown();
PACKET_CLEANUP(p);
return 1;
}
@ -8735,6 +8740,7 @@ static int StreamTcpTest41(void) {
return 1;
}
PACKET_INITIALIZE(p);
FlowInitConfig(FLOW_QUIET);
DecodeRaw(&tv, &dtv, p, raw_ip, GET_PKT_LEN(p), NULL);
@ -8764,6 +8770,7 @@ static int StreamTcpTest41(void) {
}
FlowShutdown();
PACKET_CLEANUP(p);
SCFree(p);
return 1;

Loading…
Cancel
Save