Formatting change for function call.

Put open brace { for function on a new line to match coding standard.

Changed:

int foo(int x) {
}

to:

int foo(int x)
{
}
pull/514/merge
Ken Steele 12 years ago committed by Victor Julien
parent d4dd18eb85
commit a2b502a30c

@ -1,4 +1,4 @@
/* Copyright (C) 2007-2012 Open Information Security Foundation /* Copyright (C) 2007-2013 Open Information Security Foundation
* *
* You can copy, redistribute or modify this Program under the terms of * You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free * the GNU General Public License version 2 as published by the Free
@ -42,7 +42,8 @@ SC_ATOMIC_DECLARE(unsigned int, num_tags); /**< Atomic counter, to know if we
static int host_tag_id = -1; /**< Host storage id for tags */ static int host_tag_id = -1; /**< Host storage id for tags */
static int flow_tag_id = -1; /**< Flow storage id for tags */ static int flow_tag_id = -1; /**< Flow storage id for tags */
void TagInitCtx(void) { void TagInitCtx(void)
{
SC_ATOMIC_INIT(num_tags); SC_ATOMIC_INIT(num_tags);
host_tag_id = HostStorageRegister("tag", sizeof(void *), NULL, DetectTagDataListFree); host_tag_id = HostStorageRegister("tag", sizeof(void *), NULL, DetectTagDataListFree);
@ -73,16 +74,19 @@ void TagDestroyCtx(void)
/** \brief Reset the tagging engine context /** \brief Reset the tagging engine context
*/ */
void TagRestartCtx() { void TagRestartCtx()
{
TagDestroyCtx(); TagDestroyCtx();
TagInitCtx(); TagInitCtx();
} }
int TagHostHasTag(Host *host) { int TagHostHasTag(Host *host)
{
return HostGetStorageById(host, host_tag_id) ? 1 : 0; return HostGetStorageById(host, host_tag_id) ? 1 : 0;
} }
static DetectTagDataEntry *DetectTagDataCopy(DetectTagDataEntry *dtd) { static DetectTagDataEntry *DetectTagDataCopy(DetectTagDataEntry *dtd)
{
DetectTagDataEntry *tde = SCMalloc(sizeof(DetectTagDataEntry)); DetectTagDataEntry *tde = SCMalloc(sizeof(DetectTagDataEntry));
if (unlikely(tde == NULL)) { if (unlikely(tde == NULL)) {
return NULL; return NULL;
@ -113,7 +117,8 @@ static DetectTagDataEntry *DetectTagDataCopy(DetectTagDataEntry *dtd) {
* \retval 0 if the tde was added succesfuly * \retval 0 if the tde was added succesfuly
* \retval 1 if an entry of this sid/gid already exist and was updated * \retval 1 if an entry of this sid/gid already exist and was updated
*/ */
int TagFlowAdd(Packet *p, DetectTagDataEntry *tde) { int TagFlowAdd(Packet *p, DetectTagDataEntry *tde)
{
uint8_t updated = 0; uint8_t updated = 0;
uint16_t num_tags = 0; uint16_t num_tags = 0;
DetectTagDataEntry *iter = NULL; DetectTagDataEntry *iter = NULL;
@ -240,7 +245,8 @@ int TagHashAddTag(DetectTagDataEntry *tde, Packet *p)
SCReturnInt(updated); SCReturnInt(updated);
} }
static void TagHandlePacketFlow(Flow *f, Packet *p) { static void TagHandlePacketFlow(Flow *f, Packet *p)
{
if (FlowGetStorageById(f, flow_tag_id) == NULL) if (FlowGetStorageById(f, flow_tag_id) == NULL)
return; return;
@ -354,7 +360,8 @@ static void TagHandlePacketFlow(Flow *f, Packet *p) {
} }
} }
void TagHandlePacketHost(Host *host, Packet *p) { void TagHandlePacketHost(Host *host, Packet *p)
{
DetectTagDataEntry *tde = NULL; DetectTagDataEntry *tde = NULL;
DetectTagDataEntry *prev = NULL; DetectTagDataEntry *prev = NULL;
DetectTagDataEntry *iter; DetectTagDataEntry *iter;

@ -1,4 +1,4 @@
/* Copyright (C) 2007-2010 Open Information Security Foundation /* Copyright (C) 2007-2013 Open Information Security Foundation
* *
* You can copy, redistribute or modify this Program under the terms of * You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free * the GNU General Public License version 2 as published by the Free
@ -82,7 +82,8 @@ static int DetectPcreSetup (DetectEngineCtx *, Signature *, char *);
void DetectPcreFree(void *); void DetectPcreFree(void *);
void DetectPcreRegisterTests(void); void DetectPcreRegisterTests(void);
void DetectPcreRegister (void) { void DetectPcreRegister (void)
{
sigmatch_table[DETECT_PCRE].name = "pcre"; sigmatch_table[DETECT_PCRE].name = "pcre";
sigmatch_table[DETECT_PCRE].desc = "match on regular expression"; sigmatch_table[DETECT_PCRE].desc = "match on regular expression";
sigmatch_table[DETECT_PCRE].url = "https://redmine.openinfosecfoundation.org/projects/suricata/wiki/HTTP-keywords#Pcre-Perl-Compatible-Regular-Expressions"; sigmatch_table[DETECT_PCRE].url = "https://redmine.openinfosecfoundation.org/projects/suricata/wiki/HTTP-keywords#Pcre-Perl-Compatible-Regular-Expressions";
@ -807,7 +808,8 @@ static int DetectPcreSetup (DetectEngineCtx *de_ctx, Signature *s, char *regexst
SCReturnInt(ret); SCReturnInt(ret);
} }
void DetectPcreFree(void *ptr) { void DetectPcreFree(void *ptr)
{
if (ptr == NULL) if (ptr == NULL)
return; return;
@ -829,7 +831,8 @@ void DetectPcreFree(void *ptr) {
/** /**
* \test DetectPcreParseTest01 make sure we don't allow invalid opts 7. * \test DetectPcreParseTest01 make sure we don't allow invalid opts 7.
*/ */
static int DetectPcreParseTest01 (void) { static int DetectPcreParseTest01 (void)
{
int result = 1; int result = 1;
DetectPcreData *pd = NULL; DetectPcreData *pd = NULL;
char *teststring = "/blah/7"; char *teststring = "/blah/7";
@ -851,7 +854,8 @@ static int DetectPcreParseTest01 (void) {
/** /**
* \test DetectPcreParseTest02 make sure we don't allow invalid opts Ui$. * \test DetectPcreParseTest02 make sure we don't allow invalid opts Ui$.
*/ */
static int DetectPcreParseTest02 (void) { static int DetectPcreParseTest02 (void)
{
int result = 1; int result = 1;
DetectPcreData *pd = NULL; DetectPcreData *pd = NULL;
char *teststring = "/blah/Ui$"; char *teststring = "/blah/Ui$";
@ -872,7 +876,8 @@ static int DetectPcreParseTest02 (void) {
/** /**
* \test DetectPcreParseTest03 make sure we don't allow invalid opts UZi. * \test DetectPcreParseTest03 make sure we don't allow invalid opts UZi.
*/ */
static int DetectPcreParseTest03 (void) { static int DetectPcreParseTest03 (void)
{
int result = 1; int result = 1;
DetectPcreData *pd = NULL; DetectPcreData *pd = NULL;
char *teststring = "/blah/UNi"; char *teststring = "/blah/UNi";
@ -893,7 +898,8 @@ static int DetectPcreParseTest03 (void) {
/** /**
* \test DetectPcreParseTest04 make sure we allow escaped " * \test DetectPcreParseTest04 make sure we allow escaped "
*/ */
static int DetectPcreParseTest04 (void) { static int DetectPcreParseTest04 (void)
{
int result = 1; int result = 1;
DetectPcreData *pd = NULL; DetectPcreData *pd = NULL;
char *teststring = "/b\\\"lah/i"; char *teststring = "/b\\\"lah/i";
@ -915,7 +921,8 @@ static int DetectPcreParseTest04 (void) {
/** /**
* \test DetectPcreParseTest05 make sure we parse pcre with no opts * \test DetectPcreParseTest05 make sure we parse pcre with no opts
*/ */
static int DetectPcreParseTest05 (void) { static int DetectPcreParseTest05 (void)
{
int result = 1; int result = 1;
DetectPcreData *pd = NULL; DetectPcreData *pd = NULL;
char *teststring = "/b(l|a)h/"; char *teststring = "/b(l|a)h/";
@ -937,7 +944,8 @@ static int DetectPcreParseTest05 (void) {
/** /**
* \test DetectPcreParseTest06 make sure we parse pcre with smi opts * \test DetectPcreParseTest06 make sure we parse pcre with smi opts
*/ */
static int DetectPcreParseTest06 (void) { static int DetectPcreParseTest06 (void)
{
int result = 1; int result = 1;
DetectPcreData *pd = NULL; DetectPcreData *pd = NULL;
char *teststring = "/b(l|a)h/smi"; char *teststring = "/b(l|a)h/smi";
@ -959,7 +967,8 @@ static int DetectPcreParseTest06 (void) {
/** /**
* \test DetectPcreParseTest07 make sure we parse pcre with /Ui opts * \test DetectPcreParseTest07 make sure we parse pcre with /Ui opts
*/ */
static int DetectPcreParseTest07 (void) { static int DetectPcreParseTest07 (void)
{
int result = 1; int result = 1;
DetectPcreData *pd = NULL; DetectPcreData *pd = NULL;
char *teststring = "/blah/Ui"; char *teststring = "/blah/Ui";
@ -981,7 +990,8 @@ static int DetectPcreParseTest07 (void) {
/** /**
* \test DetectPcreParseTest08 make sure we parse pcre with O opts * \test DetectPcreParseTest08 make sure we parse pcre with O opts
*/ */
static int DetectPcreParseTest08 (void) { static int DetectPcreParseTest08 (void)
{
int result = 1; int result = 1;
DetectPcreData *pd = NULL; DetectPcreData *pd = NULL;
char *teststring = "/b(l|a)h/O"; char *teststring = "/b(l|a)h/O";
@ -1004,7 +1014,8 @@ static int DetectPcreParseTest08 (void) {
* \test DetectPcreParseTest09 make sure we parse pcre with a content * \test DetectPcreParseTest09 make sure we parse pcre with a content
* that has slashes * that has slashes
*/ */
static int DetectPcreParseTest09 (void) { static int DetectPcreParseTest09 (void)
{
int result = 1; int result = 1;
DetectPcreData *pd = NULL; DetectPcreData *pd = NULL;
char *teststring = "/lala\\\\/"; char *teststring = "/lala\\\\/";
@ -1669,7 +1680,8 @@ static int DetectPcreParseTest26(void)
return result; return result;
} }
static int DetectPcreTestSig01Real(int mpm_type) { static int DetectPcreTestSig01Real(int mpm_type)
{
uint8_t *buf = (uint8_t *) uint8_t *buf = (uint8_t *)
"GET /one/ HTTP/1.1\r\n" "GET /one/ HTTP/1.1\r\n"
"Host: one.example.org\r\n" "Host: one.example.org\r\n"
@ -1747,17 +1759,21 @@ end:
UTHFreePackets(&p, 1); UTHFreePackets(&p, 1);
return result; return result;
} }
static int DetectPcreTestSig01B2g (void) { static int DetectPcreTestSig01B2g (void)
{
return DetectPcreTestSig01Real(MPM_B2G); return DetectPcreTestSig01Real(MPM_B2G);
} }
static int DetectPcreTestSig01B3g (void) { static int DetectPcreTestSig01B3g (void)
{
return DetectPcreTestSig01Real(MPM_B3G); return DetectPcreTestSig01Real(MPM_B3G);
} }
static int DetectPcreTestSig01Wm (void) { static int DetectPcreTestSig01Wm (void)
{
return DetectPcreTestSig01Real(MPM_WUMANBER); return DetectPcreTestSig01Real(MPM_WUMANBER);
} }
static int DetectPcreTestSig02Real(int mpm_type) { static int DetectPcreTestSig02Real(int mpm_type)
{
uint8_t *buf = (uint8_t *) uint8_t *buf = (uint8_t *)
"GET /one/ HTTP/1.1\r\n" "GET /one/ HTTP/1.1\r\n"
"Host: one.example.org\r\n" "Host: one.example.org\r\n"
@ -1816,20 +1832,24 @@ end:
UTHFreePackets(&p, 1); UTHFreePackets(&p, 1);
return result; return result;
} }
static int DetectPcreTestSig02B2g (void) { static int DetectPcreTestSig02B2g (void)
{
return DetectPcreTestSig02Real(MPM_B2G); return DetectPcreTestSig02Real(MPM_B2G);
} }
static int DetectPcreTestSig02B3g (void) { static int DetectPcreTestSig02B3g (void)
{
return DetectPcreTestSig02Real(MPM_B3G); return DetectPcreTestSig02Real(MPM_B3G);
} }
static int DetectPcreTestSig02Wm (void) { static int DetectPcreTestSig02Wm (void)
{
return DetectPcreTestSig02Real(MPM_WUMANBER); return DetectPcreTestSig02Real(MPM_WUMANBER);
} }
/** /**
* \test DetectPcreTestSig03Real negation test ! outside of "" this sig should not match * \test DetectPcreTestSig03Real negation test ! outside of "" this sig should not match
*/ */
static int DetectPcreTestSig03Real(int mpm_type) { static int DetectPcreTestSig03Real(int mpm_type)
{
uint8_t *buf = (uint8_t *) uint8_t *buf = (uint8_t *)
"GET /one/ HTTP/1.1\r\n" "GET /one/ HTTP/1.1\r\n"
"Host: one.example.org\r\n" "Host: one.example.org\r\n"
@ -1880,20 +1900,24 @@ end:
return result; return result;
} }
static int DetectPcreTestSig03B2g (void) { static int DetectPcreTestSig03B2g (void)
{
return DetectPcreTestSig03Real(MPM_B2G); return DetectPcreTestSig03Real(MPM_B2G);
} }
static int DetectPcreTestSig03B3g (void) { static int DetectPcreTestSig03B3g (void)
{
return DetectPcreTestSig03Real(MPM_B3G); return DetectPcreTestSig03Real(MPM_B3G);
} }
static int DetectPcreTestSig03Wm (void) { static int DetectPcreTestSig03Wm (void)
{
return DetectPcreTestSig03Real(MPM_WUMANBER); return DetectPcreTestSig03Real(MPM_WUMANBER);
} }
/** /**
* \test Check the signature with pcre modifier P (match with L7 to http body data) * \test Check the signature with pcre modifier P (match with L7 to http body data)
*/ */
static int DetectPcreModifPTest04(void) { static int DetectPcreModifPTest04(void)
{
int result = 0; int result = 0;
uint8_t httpbuf1[] = uint8_t httpbuf1[] =
"GET / HTTP/1.1\r\n" "GET / HTTP/1.1\r\n"
@ -2015,7 +2039,8 @@ end:
* \test Check the signature with pcre modifier P (match with L7 to http body data) * \test Check the signature with pcre modifier P (match with L7 to http body data)
* over fragmented chunks (DOCTYPE fragmented) * over fragmented chunks (DOCTYPE fragmented)
*/ */
static int DetectPcreModifPTest05(void) { static int DetectPcreModifPTest05(void)
{
int result = 0; int result = 0;
uint8_t httpbuf1[] = uint8_t httpbuf1[] =
"GET / HTTP/1.1\r\n" "GET / HTTP/1.1\r\n"
@ -2168,7 +2193,8 @@ end:
return result; return result;
} }
int DetectPcreTestSig06() { int DetectPcreTestSig06()
{
uint8_t *buf = (uint8_t *) uint8_t *buf = (uint8_t *)
"lalala lalala\\ lala\n"; "lalala lalala\\ lala\n";
uint16_t buflen = strlen((char *)buf); uint16_t buflen = strlen((char *)buf);
@ -2188,7 +2214,8 @@ end:
} }
/** \test anchored pcre */ /** \test anchored pcre */
int DetectPcreTestSig07() { int DetectPcreTestSig07()
{
uint8_t *buf = (uint8_t *) uint8_t *buf = (uint8_t *)
"lalala\n"; "lalala\n";
uint16_t buflen = strlen((char *)buf); uint16_t buflen = strlen((char *)buf);
@ -2208,7 +2235,8 @@ end:
} }
/** \test anchored pcre */ /** \test anchored pcre */
int DetectPcreTestSig08() { int DetectPcreTestSig08()
{
/* test it also without ending in a newline "\n" */ /* test it also without ending in a newline "\n" */
uint8_t *buf = (uint8_t *) uint8_t *buf = (uint8_t *)
"lalala"; "lalala";
@ -2231,7 +2259,8 @@ end:
/** \test Check the signature working to alert when cookie modifier is /** \test Check the signature working to alert when cookie modifier is
* passed to pcre * passed to pcre
*/ */
static int DetectPcreTestSig09(void) { static int DetectPcreTestSig09(void)
{
int result = 0; int result = 0;
Flow f; Flow f;
uint8_t httpbuf1[] = "POST / HTTP/1.0\r\nUser-Agent: Mozilla/1.0\r\n" uint8_t httpbuf1[] = "POST / HTTP/1.0\r\nUser-Agent: Mozilla/1.0\r\n"
@ -2322,7 +2351,8 @@ end:
/** \test Check the signature working to alert when cookie modifier is /** \test Check the signature working to alert when cookie modifier is
* passed to a negated pcre * passed to a negated pcre
*/ */
static int DetectPcreTestSig10(void) { static int DetectPcreTestSig10(void)
{
int result = 0; int result = 0;
Flow f; Flow f;
uint8_t httpbuf1[] = "POST / HTTP/1.0\r\nUser-Agent: Mozilla/1.0\r\n" uint8_t httpbuf1[] = "POST / HTTP/1.0\r\nUser-Agent: Mozilla/1.0\r\n"
@ -2413,7 +2443,8 @@ end:
/** \test Check the signature working to alert when method modifier is /** \test Check the signature working to alert when method modifier is
* passed to pcre * passed to pcre
*/ */
static int DetectPcreTestSig11(void) { static int DetectPcreTestSig11(void)
{
int result = 0; int result = 0;
Flow f; Flow f;
uint8_t httpbuf1[] = "POST / HTTP/1.0\r\nUser-Agent: Mozilla/1.0\r\n" uint8_t httpbuf1[] = "POST / HTTP/1.0\r\nUser-Agent: Mozilla/1.0\r\n"
@ -2504,7 +2535,8 @@ end:
/** \test Check the signature working to alert when method modifier is /** \test Check the signature working to alert when method modifier is
* passed to a negated pcre * passed to a negated pcre
*/ */
static int DetectPcreTestSig12(void) { static int DetectPcreTestSig12(void)
{
int result = 0; int result = 0;
Flow f; Flow f;
uint8_t httpbuf1[] = "GET / HTTP/1.0\r\nUser-Agent: Mozilla/1.0\r\n" uint8_t httpbuf1[] = "GET / HTTP/1.0\r\nUser-Agent: Mozilla/1.0\r\n"
@ -2595,7 +2627,8 @@ end:
/** \test Check the signature working to alert when header modifier is /** \test Check the signature working to alert when header modifier is
* passed to pcre * passed to pcre
*/ */
static int DetectPcreTestSig13(void) { static int DetectPcreTestSig13(void)
{
int result = 0; int result = 0;
Flow f; Flow f;
uint8_t httpbuf1[] = "POST / HTTP/1.0\r\nUser-Agent: Mozilla/1.0\r\n" uint8_t httpbuf1[] = "POST / HTTP/1.0\r\nUser-Agent: Mozilla/1.0\r\n"
@ -2686,7 +2719,8 @@ end:
/** \test Check the signature working to alert when header modifier is /** \test Check the signature working to alert when header modifier is
* passed to a negated pcre * passed to a negated pcre
*/ */
static int DetectPcreTestSig14(void) { static int DetectPcreTestSig14(void)
{
int result = 0; int result = 0;
Flow f; Flow f;
uint8_t httpbuf1[] = "GET / HTTP/1.0\r\nUser-Agent: IEXPLORER/1.0\r\n" uint8_t httpbuf1[] = "GET / HTTP/1.0\r\nUser-Agent: IEXPLORER/1.0\r\n"
@ -2777,7 +2811,8 @@ end:
/** \test Check the signature working to alert when cookie and relative modifiers are /** \test Check the signature working to alert when cookie and relative modifiers are
* passed to pcre * passed to pcre
*/ */
static int DetectPcreTestSig15(void) { static int DetectPcreTestSig15(void)
{
int result = 0; int result = 0;
Flow f; Flow f;
uint8_t httpbuf1[] = "POST / HTTP/1.0\r\nUser-Agent: Mozilla/1.0\r\n" uint8_t httpbuf1[] = "POST / HTTP/1.0\r\nUser-Agent: Mozilla/1.0\r\n"
@ -2869,7 +2904,8 @@ end:
/** \test Check the signature working to alert when method and relative modifiers are /** \test Check the signature working to alert when method and relative modifiers are
* passed to pcre * passed to pcre
*/ */
static int DetectPcreTestSig16(void) { static int DetectPcreTestSig16(void)
{
int result = 0; int result = 0;
Flow f; Flow f;
uint8_t httpbuf1[] = "POST / HTTP/1.0\r\nUser-Agent: Mozilla/1.0\r\n" uint8_t httpbuf1[] = "POST / HTTP/1.0\r\nUser-Agent: Mozilla/1.0\r\n"
@ -2960,7 +2996,8 @@ end:
/** \test Test tracking of body chunks per transactions (on requests) /** \test Test tracking of body chunks per transactions (on requests)
*/ */
static int DetectPcreTxBodyChunksTest01(void) { static int DetectPcreTxBodyChunksTest01(void)
{
int result = 0; int result = 0;
Flow f; Flow f;
TcpSession ssn; TcpSession ssn;
@ -3105,7 +3142,8 @@ end:
} }
/** \test test pcre P modifier with multiple pipelined http transactions */ /** \test test pcre P modifier with multiple pipelined http transactions */
static int DetectPcreTxBodyChunksTest02(void) { static int DetectPcreTxBodyChunksTest02(void)
{
int result = 0; int result = 0;
Signature *s = NULL; Signature *s = NULL;
DetectEngineThreadCtx *det_ctx = NULL; DetectEngineThreadCtx *det_ctx = NULL;
@ -3349,7 +3387,8 @@ end:
} }
/** \test multiple http transactions and body chunks of request handling */ /** \test multiple http transactions and body chunks of request handling */
static int DetectPcreTxBodyChunksTest03(void) { static int DetectPcreTxBodyChunksTest03(void)
{
int result = 0; int result = 0;
Signature *s = NULL; Signature *s = NULL;
DetectEngineThreadCtx *det_ctx = NULL; DetectEngineThreadCtx *det_ctx = NULL;
@ -3565,7 +3604,8 @@ end:
/** /**
* \test flowvar capture on http buffer * \test flowvar capture on http buffer
*/ */
static int DetectPcreFlowvarCapture01(void) { static int DetectPcreFlowvarCapture01(void)
{
int result = 0; int result = 0;
uint8_t uabuf1[] = uint8_t uabuf1[] =
"Mozilla/5.0 (X11; U; Linux i686; es-ES; rv:1.9.0.13) Gecko/2009080315 Ubuntu/8.10 (intrepid) Firefox/3.0.13"; "Mozilla/5.0 (X11; U; Linux i686; es-ES; rv:1.9.0.13) Gecko/2009080315 Ubuntu/8.10 (intrepid) Firefox/3.0.13";
@ -3686,7 +3726,8 @@ end:
/** /**
* \test flowvar capture on http buffer, capture overwrite * \test flowvar capture on http buffer, capture overwrite
*/ */
static int DetectPcreFlowvarCapture02(void) { static int DetectPcreFlowvarCapture02(void)
{
int result = 0; int result = 0;
uint8_t uabuf1[] = uint8_t uabuf1[] =
"Apache"; "Apache";
@ -3830,7 +3871,8 @@ end:
/** /**
* \test flowvar capture on http buffer, capture overwrite + no matching sigs, so flowvars should not be set. * \test flowvar capture on http buffer, capture overwrite + no matching sigs, so flowvars should not be set.
*/ */
static int DetectPcreFlowvarCapture03(void) { static int DetectPcreFlowvarCapture03(void)
{
int result = 0; int result = 0;
uint8_t httpbuf1[] = uint8_t httpbuf1[] =
"GET / HTTP/1.1\r\n" "GET / HTTP/1.1\r\n"

@ -1,4 +1,4 @@
/* Copyright (C) 2007-2012 Open Information Security Foundation /* Copyright (C) 2007-2013 Open Information Security Foundation
* *
* You can copy, redistribute or modify this Program under the terms of * You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free * the GNU General Public License version 2 as published by the Free
@ -33,7 +33,8 @@
#include "util-debug.h" #include "util-debug.h"
#include "util-print.h" #include "util-print.h"
FlowQueue *FlowQueueNew() { FlowQueue *FlowQueueNew()
{
FlowQueue *q = (FlowQueue *)SCMalloc(sizeof(FlowQueue)); FlowQueue *q = (FlowQueue *)SCMalloc(sizeof(FlowQueue));
if (q == NULL) { if (q == NULL) {
SCLogError(SC_ERR_FATAL, "Fatal error encountered in FlowQueueNew. Exiting..."); SCLogError(SC_ERR_FATAL, "Fatal error encountered in FlowQueueNew. Exiting...");
@ -43,7 +44,8 @@ FlowQueue *FlowQueueNew() {
return q; return q;
} }
FlowQueue *FlowQueueInit (FlowQueue *q) { FlowQueue *FlowQueueInit (FlowQueue *q)
{
if (q != NULL) { if (q != NULL) {
memset(q, 0, sizeof(FlowQueue)); memset(q, 0, sizeof(FlowQueue));
FQLOCK_INIT(q); FQLOCK_INIT(q);
@ -56,7 +58,8 @@ FlowQueue *FlowQueueInit (FlowQueue *q) {
* *
* \param q the flow queue to destroy * \param q the flow queue to destroy
*/ */
void FlowQueueDestroy (FlowQueue *q) { void FlowQueueDestroy (FlowQueue *q)
{
FQLOCK_DESTROY(q); FQLOCK_DESTROY(q);
} }
@ -66,7 +69,8 @@ void FlowQueueDestroy (FlowQueue *q) {
* \param q queue * \param q queue
* \param f flow * \param f flow
*/ */
void FlowEnqueue (FlowQueue *q, Flow *f) { void FlowEnqueue (FlowQueue *q, Flow *f)
{
#ifdef DEBUG #ifdef DEBUG
BUG_ON(q == NULL || f == NULL); BUG_ON(q == NULL || f == NULL);
#endif #endif
@ -98,7 +102,8 @@ void FlowEnqueue (FlowQueue *q, Flow *f) {
* *
* \retval f flow or NULL if empty list. * \retval f flow or NULL if empty list.
*/ */
Flow *FlowDequeue (FlowQueue *q) { Flow *FlowDequeue (FlowQueue *q)
{
FQLOCK_LOCK(q); FQLOCK_LOCK(q);
Flow *f = q->bot; Flow *f = q->bot;

@ -1,4 +1,4 @@
/* Copyright (C) 2007-2010 Open Information Security Foundation /* Copyright (C) 2007-2013 Open Information Security Foundation
* *
* You can copy, redistribute or modify this Program under the terms of * You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free * the GNU General Public License version 2 as published by the Free
@ -50,7 +50,8 @@ uint8_t action_order_sigs[4] = {ACTION_PASS, ACTION_DROP, ACTION_REJECT, ACTION_
* ACTION_REJECT or ACTION_ALERT * ACTION_REJECT or ACTION_ALERT
* \retval uint8_t the priority (order of this actions) * \retval uint8_t the priority (order of this actions)
*/ */
uint8_t ActionOrderVal(uint8_t action) { uint8_t ActionOrderVal(uint8_t action)
{
/* reject_both and reject_dst have the same prio as reject */ /* reject_both and reject_dst have the same prio as reject */
if( (action & ACTION_REJECT) || if( (action & ACTION_REJECT) ||
(action & ACTION_REJECT_BOTH) || (action & ACTION_REJECT_BOTH) ||
@ -73,7 +74,8 @@ uint8_t ActionOrderVal(uint8_t action) {
* \retval uint8_t can be one of ACTION_PASS, ACTION_DROP, * \retval uint8_t can be one of ACTION_PASS, ACTION_DROP,
* ACTION_REJECT or ACTION_ALERT * ACTION_REJECT or ACTION_ALERT
*/ */
uint8_t ActionAsciiToFlag(char *action) { uint8_t ActionAsciiToFlag(char *action)
{
if (strcmp(action,"pass") == 0) if (strcmp(action,"pass") == 0)
return ACTION_PASS; return ACTION_PASS;
if (strcmp(action,"drop") == 0) if (strcmp(action,"drop") == 0)
@ -93,7 +95,8 @@ uint8_t ActionAsciiToFlag(char *action) {
* *
* \retval 0 on success; -1 on fatal error; * \retval 0 on success; -1 on fatal error;
*/ */
int ActionInitConfig() { int ActionInitConfig()
{
uint8_t actions_used = 0; uint8_t actions_used = 0;
uint8_t action_flag = 0; uint8_t action_flag = 0;
uint8_t actions_config[4] = {0, 0, 0, 0}; uint8_t actions_config[4] = {0, 0, 0, 0};

@ -54,7 +54,8 @@
* \retval 0 if the syscall is not available or we have an error; * \retval 0 if the syscall is not available or we have an error;
* otherwise it will return the number of cpus configured * otherwise it will return the number of cpus configured
*/ */
uint16_t UtilCpuGetNumProcessorsConfigured() { uint16_t UtilCpuGetNumProcessorsConfigured()
{
#ifdef SYSCONF_NPROCESSORS_CONF_COMPAT #ifdef SYSCONF_NPROCESSORS_CONF_COMPAT
long nprocs = -1; long nprocs = -1;
nprocs = sysconf(_SC_NPROCESSORS_CONF); nprocs = sysconf(_SC_NPROCESSORS_CONF);
@ -94,7 +95,8 @@ uint16_t UtilCpuGetNumProcessorsConfigured() {
* \retval 0 if the syscall is not available or we have an error; * \retval 0 if the syscall is not available or we have an error;
* otherwise it will return the number of cpus online * otherwise it will return the number of cpus online
*/ */
uint16_t UtilCpuGetNumProcessorsOnline() { uint16_t UtilCpuGetNumProcessorsOnline()
{
#ifdef SYSCONF_NPROCESSORS_ONLN_COMPAT #ifdef SYSCONF_NPROCESSORS_ONLN_COMPAT
long nprocs = -1; long nprocs = -1;
nprocs = sysconf(_SC_NPROCESSORS_ONLN); nprocs = sysconf(_SC_NPROCESSORS_ONLN);
@ -128,7 +130,8 @@ uint16_t UtilCpuGetNumProcessorsOnline() {
* \retval 0 if the syscall is not available or we have an error; * \retval 0 if the syscall is not available or we have an error;
* otherwise it will return the number of cpus allowed * otherwise it will return the number of cpus allowed
*/ */
uint16_t UtilCpuGetNumProcessorsMax() { uint16_t UtilCpuGetNumProcessorsMax()
{
#ifdef SYSCONF_NPROCESSORS_MAX_COMPAT #ifdef SYSCONF_NPROCESSORS_MAX_COMPAT
long nprocs = -1; long nprocs = -1;
nprocs = sysconf(_SC_NPROCESSORS_MAX); nprocs = sysconf(_SC_NPROCESSORS_MAX);
@ -155,7 +158,8 @@ uint16_t UtilCpuGetNumProcessorsMax() {
/** /**
* \brief Print a summary of CPUs detected (configured and online) * \brief Print a summary of CPUs detected (configured and online)
*/ */
void UtilCpuPrintSummary() { void UtilCpuPrintSummary()
{
uint16_t cpus_conf = UtilCpuGetNumProcessorsConfigured(); uint16_t cpus_conf = UtilCpuGetNumProcessorsConfigured();
uint16_t cpus_online = UtilCpuGetNumProcessorsOnline(); uint16_t cpus_online = UtilCpuGetNumProcessorsOnline();

@ -1,4 +1,4 @@
/* Copyright (C) 2007-2010 Open Information Security Foundation /* Copyright (C) 2007-2013 Open Information Security Foundation
* *
* You can copy, redistribute or modify this Program under the terms of * You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free * the GNU General Public License version 2 as published by the Free
@ -35,7 +35,8 @@
uint16_t asn1_max_frames_config = ASN1_MAX_FRAMES; uint16_t asn1_max_frames_config = ASN1_MAX_FRAMES;
void SCAsn1LoadConfig() { void SCAsn1LoadConfig()
{
intmax_t value = 0; intmax_t value = 0;
/** set config defaults */ /** set config defaults */
@ -54,7 +55,8 @@ void SCAsn1LoadConfig() {
* *
* \retval byte of the status of the parser * \retval byte of the status of the parser
*/ */
uint8_t SCAsn1GetHighTagNumber(Asn1Ctx *ac) { uint8_t SCAsn1GetHighTagNumber(Asn1Ctx *ac)
{
uint8_t ret = 0; uint8_t ret = 0;
uint32_t tag_num = 0; uint32_t tag_num = 0;
@ -117,7 +119,8 @@ uint8_t SCAsn1GetHighTagNumber(Asn1Ctx *ac) {
* *
* \retval byte of the status of the parser * \retval byte of the status of the parser
*/ */
uint32_t SCAsn1GetLengthLongForm(Asn1Ctx *ac) { uint32_t SCAsn1GetLengthLongForm(Asn1Ctx *ac)
{
uint8_t raw_len = *ac->iter; uint8_t raw_len = *ac->iter;
uint8_t ret = 0; uint8_t ret = 0;
uint32_t content_len = 0; uint32_t content_len = 0;
@ -169,7 +172,8 @@ uint32_t SCAsn1GetLengthLongForm(Asn1Ctx *ac) {
* *
* \retval byte of the status of the parser * \retval byte of the status of the parser
*/ */
uint8_t SCAsn1DecodeContent(Asn1Ctx *ac) { uint8_t SCAsn1DecodeContent(Asn1Ctx *ac)
{
Asn1Node *node = ASN1CTX_CUR_NODE(ac); Asn1Node *node = ASN1CTX_CUR_NODE(ac);
@ -208,7 +212,8 @@ uint8_t SCAsn1DecodeContent(Asn1Ctx *ac) {
* *
* \retval byte of the status of the parser * \retval byte of the status of the parser
*/ */
uint8_t SCAsn1DecodeLength(Asn1Ctx *ac) { uint8_t SCAsn1DecodeLength(Asn1Ctx *ac)
{
uint8_t ret = 0; uint8_t ret = 0;
ret = SCAsn1CheckBounds(ac); ret = SCAsn1CheckBounds(ac);
if (ret == ASN1_PARSER_ERR) { if (ret == ASN1_PARSER_ERR) {
@ -277,7 +282,8 @@ uint8_t SCAsn1DecodeLength(Asn1Ctx *ac) {
* *
* \retval byte of the status of the parser * \retval byte of the status of the parser
*/ */
uint8_t SCAsn1DecodeIdentifier(Asn1Ctx *ac) { uint8_t SCAsn1DecodeIdentifier(Asn1Ctx *ac)
{
uint8_t ret = 0; uint8_t ret = 0;
ret = SCAsn1CheckBounds(ac); ret = SCAsn1CheckBounds(ac);
if (ret == ASN1_PARSER_ERR) { if (ret == ASN1_PARSER_ERR) {
@ -309,7 +315,8 @@ uint8_t SCAsn1DecodeIdentifier(Asn1Ctx *ac) {
* to check encoding internals * to check encoding internals
* \param byte value of the byte * \param byte value of the byte
*/ */
void SCPrintByteBin(uint8_t byte) { void SCPrintByteBin(uint8_t byte)
{
uint8_t i = 0; uint8_t i = 0;
for (i = 8; i > 0; i--) { for (i = 8; i > 0; i--) {
printf("%"PRIu8, ((byte >> (i - 1)) & 0x01)); printf("%"PRIu8, ((byte >> (i - 1)) & 0x01));
@ -325,7 +332,8 @@ void SCPrintByteBin(uint8_t byte) {
* \param ac Asn1Ctx pointer initialized * \param ac Asn1Ctx pointer initialized
* \retval 1 if we are out of bounds, 0 if not * \retval 1 if we are out of bounds, 0 if not
*/ */
uint8_t SCAsn1CheckBounds(Asn1Ctx *ac) { uint8_t SCAsn1CheckBounds(Asn1Ctx *ac)
{
return (ac->iter < ac->end && ac->iter >= ac->data)? ASN1_PARSER_OK : ASN1_PARSER_ERR; return (ac->iter < ac->end && ac->iter >= ac->data)? ASN1_PARSER_OK : ASN1_PARSER_ERR;
} }
@ -335,7 +343,8 @@ uint8_t SCAsn1CheckBounds(Asn1Ctx *ac) {
* *
* \retval Asn1Ctx pointer to the new ctx * \retval Asn1Ctx pointer to the new ctx
*/ */
Asn1Ctx *SCAsn1CtxNew(void) { Asn1Ctx *SCAsn1CtxNew(void)
{
Asn1Ctx *ac = SCMalloc(sizeof(Asn1Ctx)); Asn1Ctx *ac = SCMalloc(sizeof(Asn1Ctx));
if (unlikely(ac == NULL)) { if (unlikely(ac == NULL)) {
@ -359,7 +368,8 @@ Asn1Ctx *SCAsn1CtxNew(void) {
* *
* \param Asn1Ctx pointer to the new ctx * \param Asn1Ctx pointer to the new ctx
*/ */
void SCAsn1CtxDestroy(Asn1Ctx *ac) { void SCAsn1CtxDestroy(Asn1Ctx *ac)
{
if (ac == NULL) if (ac == NULL)
return; return;
@ -382,7 +392,8 @@ void SCAsn1CtxDestroy(Asn1Ctx *ac) {
* *
* \retval Asn1Node pointer to the new node allocated * \retval Asn1Node pointer to the new node allocated
*/ */
Asn1Node *SCAsn1CtxNewFrame(Asn1Ctx *ac, uint16_t node) { Asn1Node *SCAsn1CtxNewFrame(Asn1Ctx *ac, uint16_t node)
{
if (node >= asn1_max_frames_config) { if (node >= asn1_max_frames_config) {
return NULL; return NULL;
} }
@ -406,8 +417,8 @@ Asn1Node *SCAsn1CtxNewFrame(Asn1Ctx *ac, uint16_t node) {
* *
* \retval void * \retval void
*/ */
void SCAsn1CtxInit(Asn1Ctx *ac, uint8_t *data, uint16_t length) { void SCAsn1CtxInit(Asn1Ctx *ac, uint8_t *data, uint16_t length)
{
ac->data = data; ac->data = data;
ac->iter = data; ac->iter = data;
ac->len = length; ac->len = length;
@ -423,7 +434,8 @@ void SCAsn1CtxInit(Asn1Ctx *ac, uint8_t *data, uint16_t length) {
* *
* \retval byte of parser status * \retval byte of parser status
*/ */
uint8_t SCAsn1Decode(Asn1Ctx *ac, uint16_t node_id) { uint8_t SCAsn1Decode(Asn1Ctx *ac, uint16_t node_id)
{
Asn1Node *node = NULL; Asn1Node *node = NULL;
uint8_t ret = 0; uint8_t ret = 0;
@ -528,7 +540,8 @@ uint8_t SCAsn1Decode(Asn1Ctx *ac, uint16_t node_id) {
/** /**
* \test Check we handle extended identifiers correctly * \test Check we handle extended identifiers correctly
*/ */
int DecodeAsn1Test01(void) { int DecodeAsn1Test01(void)
{
uint8_t *str = (uint8_t *) "\x3F\x84\x06"; uint8_t *str = (uint8_t *) "\x3F\x84\x06";
Asn1Ctx *ac = SCAsn1CtxNew(); Asn1Ctx *ac = SCAsn1CtxNew();
@ -556,7 +569,8 @@ end:
/** /**
* \test Check we handle extended identifiers correctly * \test Check we handle extended identifiers correctly
*/ */
int DecodeAsn1Test02(void) { int DecodeAsn1Test02(void)
{
uint8_t *str = (uint8_t *) "\x3F\x81\x81\x81\x81\x06"; uint8_t *str = (uint8_t *) "\x3F\x81\x81\x81\x81\x06";
Asn1Ctx *ac = SCAsn1CtxNew(); Asn1Ctx *ac = SCAsn1CtxNew();
@ -584,7 +598,8 @@ end:
/** /**
* \test Check we handle short identifiers correctly * \test Check we handle short identifiers correctly
*/ */
int DecodeAsn1Test03(void) { int DecodeAsn1Test03(void)
{
uint8_t *str = (uint8_t *) "\x28"; uint8_t *str = (uint8_t *) "\x28";
Asn1Ctx *ac = SCAsn1CtxNew(); Asn1Ctx *ac = SCAsn1CtxNew();
@ -612,7 +627,8 @@ end:
/** /**
* \test Check we handle extended lengths correctly with indefinite form * \test Check we handle extended lengths correctly with indefinite form
*/ */
int DecodeAsn1Test04(void) { int DecodeAsn1Test04(void)
{
uint8_t *str = (uint8_t *) "\x3F\x84\x06\x80\x12\x12\x12\x00\x00"; uint8_t *str = (uint8_t *) "\x3F\x84\x06\x80\x12\x12\x12\x00\x00";
Asn1Ctx *ac = SCAsn1CtxNew(); Asn1Ctx *ac = SCAsn1CtxNew();
@ -641,7 +657,8 @@ end:
* \test Check we handle extended lengths correctly * \test Check we handle extended lengths correctly
* in the definite form * in the definite form
*/ */
int DecodeAsn1Test05(void) { int DecodeAsn1Test05(void)
{
uint8_t *str = (uint8_t *) "\x3F\x84\x06\x82\x10\x10"; uint8_t *str = (uint8_t *) "\x3F\x84\x06\x82\x10\x10";
Asn1Ctx *ac = SCAsn1CtxNew(); Asn1Ctx *ac = SCAsn1CtxNew();
@ -669,7 +686,8 @@ end:
/** /**
* \test Check we handle short lengths correctly * \test Check we handle short lengths correctly
*/ */
int DecodeAsn1Test06(void) { int DecodeAsn1Test06(void)
{
uint8_t *str = (uint8_t *) "\x3F\x84\x06\x26"; uint8_t *str = (uint8_t *) "\x3F\x84\x06\x26";
Asn1Ctx *ac = SCAsn1CtxNew(); Asn1Ctx *ac = SCAsn1CtxNew();
@ -697,7 +715,8 @@ end:
/** /**
* \test Check we handle events correctly * \test Check we handle events correctly
*/ */
int DecodeAsn1Test07(void) { int DecodeAsn1Test07(void)
{
uint8_t *str = (uint8_t *) "\x3F\x00\x84\x06"; uint8_t *str = (uint8_t *) "\x3F\x00\x84\x06";
Asn1Ctx *ac = SCAsn1CtxNew(); Asn1Ctx *ac = SCAsn1CtxNew();
@ -727,7 +746,8 @@ end:
/** /**
* \test Check we handle events correctly * \test Check we handle events correctly
*/ */
int DecodeAsn1Test08(void) { int DecodeAsn1Test08(void)
{
uint8_t *str = (uint8_t *) "\x3F\x84\x06\x81\xFF"; uint8_t *str = (uint8_t *) "\x3F\x84\x06\x81\xFF";
Asn1Ctx *ac = SCAsn1CtxNew(); Asn1Ctx *ac = SCAsn1CtxNew();
@ -757,7 +777,8 @@ end:
/** /**
* \test Check we handle events correctly * \test Check we handle events correctly
*/ */
int DecodeAsn1Test09(void) { int DecodeAsn1Test09(void)
{
uint8_t *str = (uint8_t *) "\x3F\x84\x06\x80\xAB\xCD\xEF"; uint8_t *str = (uint8_t *) "\x3F\x84\x06\x80\xAB\xCD\xEF";
Asn1Ctx *ac = SCAsn1CtxNew(); Asn1Ctx *ac = SCAsn1CtxNew();
@ -787,7 +808,8 @@ end:
/** /**
* \test Decode a big chunk of data * \test Decode a big chunk of data
*/ */
int DecodeAsn1Test10(void) { int DecodeAsn1Test10(void)
{
// Example from the specification X.690-0207 Appendix A.3 // Example from the specification X.690-0207 Appendix A.3
uint8_t *str = (uint8_t *) "\x60\x81\x85\x61\x10\x1A\x04""John""\x1A\x01" uint8_t *str = (uint8_t *) "\x60\x81\x85\x61\x10\x1A\x04""John""\x1A\x01"
"P""\x1A\x05""Smith""\xA0\x0A\x1A\x08""Director" "P""\x1A\x05""Smith""\xA0\x0A\x1A\x08""Director"
@ -861,7 +883,8 @@ end:
#endif #endif
void DecodeAsn1RegisterTests(void) { void DecodeAsn1RegisterTests(void)
{
#ifdef UNITTESTS #ifdef UNITTESTS
UtRegisterTest("DecodeAsn1Test01", DecodeAsn1Test01, 1); UtRegisterTest("DecodeAsn1Test01", DecodeAsn1Test01, 1);
UtRegisterTest("DecodeAsn1Test02", DecodeAsn1Test02, 1); UtRegisterTest("DecodeAsn1Test02", DecodeAsn1Test02, 1);

@ -1,4 +1,4 @@
/* Copyright (C) 2007-2011 Open Information Security Foundation /* Copyright (C) 2007-2013 Open Information Security Foundation
* *
* You can copy, redistribute or modify this Program under the terms of * You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free * the GNU General Public License version 2 as published by the Free
@ -39,7 +39,8 @@ static SCMutex g_magic_lock;
/** /**
* \brief Initialize the "magic" context. * \brief Initialize the "magic" context.
*/ */
int MagicInit(void) { int MagicInit(void)
{
BUG_ON(g_magic_ctx != NULL); BUG_ON(g_magic_ctx != NULL);
SCEnter(); SCEnter();
@ -93,7 +94,8 @@ error:
* *
* \retval result pointer to null terminated string * \retval result pointer to null terminated string
*/ */
char *MagicGlobalLookup(uint8_t *buf, uint32_t buflen) { char *MagicGlobalLookup(uint8_t *buf, uint32_t buflen)
{
const char *result = NULL; const char *result = NULL;
char *magic = NULL; char *magic = NULL;
@ -121,7 +123,8 @@ char *MagicGlobalLookup(uint8_t *buf, uint32_t buflen) {
* *
* \retval result pointer to null terminated string * \retval result pointer to null terminated string
*/ */
char *MagicThreadLookup(magic_t *ctx, uint8_t *buf, uint32_t buflen) { char *MagicThreadLookup(magic_t *ctx, uint8_t *buf, uint32_t buflen)
{
const char *result = NULL; const char *result = NULL;
char *magic = NULL; char *magic = NULL;
@ -138,7 +141,8 @@ char *MagicThreadLookup(magic_t *ctx, uint8_t *buf, uint32_t buflen) {
SCReturnPtr(magic, "const char"); SCReturnPtr(magic, "const char");
} }
void MagicDeinit(void) { void MagicDeinit(void)
{
SCMutexLock(&g_magic_lock); SCMutexLock(&g_magic_lock);
if (g_magic_ctx != NULL) { if (g_magic_ctx != NULL) {
magic_close(g_magic_ctx); magic_close(g_magic_ctx);
@ -288,7 +292,8 @@ end:
} }
/** \test magic lib calls -- lookup */ /** \test magic lib calls -- lookup */
int MagicDetectTest03(void) { int MagicDetectTest03(void)
{
magic_t magic_ctx; magic_t magic_ctx;
char *result = NULL; char *result = NULL;
@ -343,7 +348,8 @@ end:
} }
/** \test magic lib calls -- lookup */ /** \test magic lib calls -- lookup */
int MagicDetectTest04(void) { int MagicDetectTest04(void)
{
magic_t magic_ctx; magic_t magic_ctx;
char *result = NULL; char *result = NULL;
@ -404,7 +410,8 @@ end:
} }
/** \test magic api calls -- lookup */ /** \test magic api calls -- lookup */
int MagicDetectTest05(void) { int MagicDetectTest05(void)
{
const char *result = NULL; const char *result = NULL;
uint8_t buffer[] = { 0x25, 'P', 'D', 'F', '-', '1', '.', '3', 0x0d, 0x0a}; uint8_t buffer[] = { 0x25, 'P', 'D', 'F', '-', '1', '.', '3', 0x0d, 0x0a};
size_t buffer_len = sizeof(buffer); size_t buffer_len = sizeof(buffer);
@ -428,7 +435,8 @@ end:
} }
/** \test magic api calls -- lookup */ /** \test magic api calls -- lookup */
int MagicDetectTest06(void) { int MagicDetectTest06(void)
{
const char *result = NULL; const char *result = NULL;
uint8_t buffer[] = { uint8_t buffer[] = {
0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1, 0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1,
@ -468,7 +476,8 @@ end:
} }
/** \test magic api calls -- lookup */ /** \test magic api calls -- lookup */
int MagicDetectTest07(void) { int MagicDetectTest07(void)
{
const char *result = NULL; const char *result = NULL;
uint8_t buffer[] = { uint8_t buffer[] = {
0x50, 0x4b, 0x03, 0x04, 0x14, 0x00, 0x00, 0x00, 0x50, 0x4b, 0x03, 0x04, 0x14, 0x00, 0x00, 0x00,
@ -515,7 +524,8 @@ end:
} }
/** \test magic api calls -- lookup */ /** \test magic api calls -- lookup */
int MagicDetectTest08(void) { int MagicDetectTest08(void)
{
const char *result = NULL; const char *result = NULL;
uint8_t buffer[] = { uint8_t buffer[] = {
0x50, 0x4b, 0x03, 0x04, 0x14, 0x00, 0x00, 0x08, 0x50, 0x4b, 0x03, 0x04, 0x14, 0x00, 0x00, 0x08,
@ -568,7 +578,8 @@ end:
} }
/** \test magic api calls -- make sure memory is shared */ /** \test magic api calls -- make sure memory is shared */
int MagicDetectTest09(void) { int MagicDetectTest09(void)
{
const char *result1 = NULL; const char *result1 = NULL;
const char *result2 = NULL; const char *result2 = NULL;
uint8_t buffer[] = { 0x25, 'P', 'D', 'F', '-', '1', '.', '3', 0x0d, 0x0a}; uint8_t buffer[] = { 0x25, 'P', 'D', 'F', '-', '1', '.', '3', 0x0d, 0x0a};
@ -605,7 +616,8 @@ end:
/** \test results in valgrind warning about invalid read, tested with /** \test results in valgrind warning about invalid read, tested with
* file 5.09 and 5.11 */ * file 5.09 and 5.11 */
static int MagicDetectTest10ValgrindError(void) { static int MagicDetectTest10ValgrindError(void)
{
const char *result = NULL; const char *result = NULL;
uint8_t buffer[] = { uint8_t buffer[] = {
0xFF,0xD8,0xFF,0xE0,0x00,0x10,0x4A,0x46,0x49,0x46,0x00,0x01,0x01,0x01,0x01,0x2C, 0xFF,0xD8,0xFF,0xE0,0x00,0x10,0x4A,0x46,0x49,0x46,0x00,0x01,0x01,0x01,0x01,0x2C,
@ -643,7 +655,8 @@ end:
#endif /* UNITTESTS */ #endif /* UNITTESTS */
void MagicRegisterTests(void) { void MagicRegisterTests(void)
{
#ifdef UNITTESTS #ifdef UNITTESTS
UtRegisterTest("MagicInitTest01", MagicInitTest01, 1); UtRegisterTest("MagicInitTest01", MagicInitTest01, 1);
UtRegisterTest("MagicInitTest02", MagicInitTest02, 1); UtRegisterTest("MagicInitTest02", MagicInitTest02, 1);

@ -1,4 +1,4 @@
/* Copyright (C) 2007-2010 Open Information Security Foundation /* Copyright (C) 2007-2013 Open Information Security Foundation
* *
* You can copy, redistribute or modify this Program under the terms of * You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free * the GNU General Public License version 2 as published by the Free
@ -68,7 +68,8 @@
* \param needle pattern to search for * \param needle pattern to search for
* \param needlelen length of the pattern * \param needlelen length of the pattern
*/ */
uint8_t *Bs2bmSearch(uint8_t *text, uint32_t textlen, uint8_t *needle, uint16_t needlelen) { uint8_t *Bs2bmSearch(uint8_t *text, uint32_t textlen, uint8_t *needle, uint16_t needlelen)
{
uint8_t badchars[ALPHABET_SIZE]; uint8_t badchars[ALPHABET_SIZE];
Bs2BmBadchars(needle, needlelen, badchars); Bs2BmBadchars(needle, needlelen, badchars);
@ -83,7 +84,8 @@ uint8_t *Bs2bmSearch(uint8_t *text, uint32_t textlen, uint8_t *needle, uint16_t
* \param needle pattern to search for * \param needle pattern to search for
* \param needlelen length of the pattern * \param needlelen length of the pattern
*/ */
uint8_t *Bs2bmNocaseSearch(uint8_t *text, uint32_t textlen, uint8_t *needle, uint16_t needlelen) { uint8_t *Bs2bmNocaseSearch(uint8_t *text, uint32_t textlen, uint8_t *needle, uint16_t needlelen)
{
uint8_t badchars[ALPHABET_SIZE]; uint8_t badchars[ALPHABET_SIZE];
Bs2BmBadchars(needle, needlelen, badchars); Bs2BmBadchars(needle, needlelen, badchars);
@ -99,7 +101,8 @@ uint8_t *Bs2bmNocaseSearch(uint8_t *text, uint32_t textlen, uint8_t *needle, uin
* \param needle pattern to search for * \param needle pattern to search for
* \param needlelen length of the pattern * \param needlelen length of the pattern
*/ */
uint8_t *BoyerMooreSearch(uint8_t *text, uint32_t textlen, uint8_t *needle, uint16_t needlelen) { uint8_t *BoyerMooreSearch(uint8_t *text, uint32_t textlen, uint8_t *needle, uint16_t needlelen)
{
uint16_t bmBc[ALPHABET_SIZE]; uint16_t bmBc[ALPHABET_SIZE];
uint16_t *bmGs = SCMalloc(sizeof(uint16_t)*(needlelen + 1)); uint16_t *bmGs = SCMalloc(sizeof(uint16_t)*(needlelen + 1));
if (unlikely(bmGs == NULL)) if (unlikely(bmGs == NULL))
@ -123,7 +126,8 @@ uint8_t *BoyerMooreSearch(uint8_t *text, uint32_t textlen, uint8_t *needle, uint
* \param needle pattern to search for * \param needle pattern to search for
* \param needlelen length of the pattern * \param needlelen length of the pattern
*/ */
uint8_t *BoyerMooreNocaseSearch(uint8_t *text, uint32_t textlen, uint8_t *needle, uint16_t needlelen) { uint8_t *BoyerMooreNocaseSearch(uint8_t *text, uint32_t textlen, uint8_t *needle, uint16_t needlelen)
{
uint16_t bmBc[ALPHABET_SIZE]; uint16_t bmBc[ALPHABET_SIZE];
uint16_t *bmGs = SCMalloc(sizeof(uint16_t)*(needlelen + 1)); uint16_t *bmGs = SCMalloc(sizeof(uint16_t)*(needlelen + 1));
if (unlikely(bmGs == NULL)) if (unlikely(bmGs == NULL))
@ -155,7 +159,8 @@ uint8_t *BoyerMooreNocaseSearch(uint8_t *text, uint32_t textlen, uint8_t *needle
* \param times If you are testing performance, se the numebr of times * \param times If you are testing performance, se the numebr of times
* that you want to repeat the search * that you want to repeat the search
*/ */
uint8_t *BasicSearchWrapper(uint8_t *text, uint8_t *needle, int times) { uint8_t *BasicSearchWrapper(uint8_t *text, uint8_t *needle, int times)
{
uint32_t textlen = strlen((char *)text); uint32_t textlen = strlen((char *)text);
uint16_t needlelen = strlen((char *)needle); uint16_t needlelen = strlen((char *)needle);
@ -174,7 +179,8 @@ uint8_t *BasicSearchWrapper(uint8_t *text, uint8_t *needle, int times) {
return ret; return ret;
} }
uint8_t *BasicSearchNocaseWrapper(uint8_t *text, uint8_t *needle, int times) { uint8_t *BasicSearchNocaseWrapper(uint8_t *text, uint8_t *needle, int times)
{
uint32_t textlen = strlen((char *)text); uint32_t textlen = strlen((char *)text);
uint16_t needlelen = strlen((char *)needle); uint16_t needlelen = strlen((char *)needle);
@ -190,7 +196,8 @@ uint8_t *BasicSearchNocaseWrapper(uint8_t *text, uint8_t *needle, int times) {
return ret; return ret;
} }
uint8_t *Bs2bmWrapper(uint8_t *text, uint8_t *needle, int times) { uint8_t *Bs2bmWrapper(uint8_t *text, uint8_t *needle, int times)
{
uint32_t textlen = strlen((char *)text); uint32_t textlen = strlen((char *)text);
uint16_t needlelen = strlen((char *)needle); uint16_t needlelen = strlen((char *)needle);
@ -209,7 +216,8 @@ uint8_t *Bs2bmWrapper(uint8_t *text, uint8_t *needle, int times) {
return ret; return ret;
} }
uint8_t *Bs2bmNocaseWrapper(uint8_t *text, uint8_t *needle, int times) { uint8_t *Bs2bmNocaseWrapper(uint8_t *text, uint8_t *needle, int times)
{
uint32_t textlen = strlen((char *)text); uint32_t textlen = strlen((char *)text);
uint16_t needlelen = strlen((char *)needle); uint16_t needlelen = strlen((char *)needle);
@ -228,7 +236,8 @@ uint8_t *Bs2bmNocaseWrapper(uint8_t *text, uint8_t *needle, int times) {
return ret; return ret;
} }
uint8_t *BoyerMooreWrapper(uint8_t *text, uint8_t *needle, int times) { uint8_t *BoyerMooreWrapper(uint8_t *text, uint8_t *needle, int times)
{
uint32_t textlen = strlen((char *)text); uint32_t textlen = strlen((char *)text);
uint16_t needlelen = strlen((char *)needle); uint16_t needlelen = strlen((char *)needle);
@ -253,7 +262,8 @@ uint8_t *BoyerMooreWrapper(uint8_t *text, uint8_t *needle, int times) {
return ret; return ret;
} }
uint8_t *BoyerMooreNocaseWrapper(uint8_t *text, uint8_t *needle, int times) { uint8_t *BoyerMooreNocaseWrapper(uint8_t *text, uint8_t *needle, int times)
{
uint32_t textlen = strlen((char *)text); uint32_t textlen = strlen((char *)text);
uint16_t needlelen = strlen((char *)needle); uint16_t needlelen = strlen((char *)needle);
@ -286,7 +296,8 @@ uint8_t *BoyerMooreNocaseWrapper(uint8_t *text, uint8_t *needle, int times) {
* \param times If you are testing performance, se the numebr of times * \param times If you are testing performance, se the numebr of times
* that you want to repeat the search * that you want to repeat the search
*/ */
uint8_t *BasicSearchCtxWrapper(uint8_t *text, uint8_t *needle, int times) { uint8_t *BasicSearchCtxWrapper(uint8_t *text, uint8_t *needle, int times)
{
uint32_t textlen = strlen((char *)text); uint32_t textlen = strlen((char *)text);
uint16_t needlelen = strlen((char *)needle); uint16_t needlelen = strlen((char *)needle);
@ -303,7 +314,8 @@ uint8_t *BasicSearchCtxWrapper(uint8_t *text, uint8_t *needle, int times) {
return ret; return ret;
} }
uint8_t *BasicSearchNocaseCtxWrapper(uint8_t *text, uint8_t *needle, int times) { uint8_t *BasicSearchNocaseCtxWrapper(uint8_t *text, uint8_t *needle, int times)
{
uint32_t textlen = strlen((char *)text); uint32_t textlen = strlen((char *)text);
uint16_t needlelen = strlen((char *)needle); uint16_t needlelen = strlen((char *)needle);
@ -320,7 +332,8 @@ uint8_t *BasicSearchNocaseCtxWrapper(uint8_t *text, uint8_t *needle, int times)
return ret; return ret;
} }
uint8_t *Bs2bmCtxWrapper(uint8_t *text, uint8_t *needle, int times) { uint8_t *Bs2bmCtxWrapper(uint8_t *text, uint8_t *needle, int times)
{
uint32_t textlen = strlen((char *)text); uint32_t textlen = strlen((char *)text);
uint16_t needlelen = strlen((char *)needle); uint16_t needlelen = strlen((char *)needle);
@ -340,7 +353,8 @@ uint8_t *Bs2bmCtxWrapper(uint8_t *text, uint8_t *needle, int times) {
return ret; return ret;
} }
uint8_t *Bs2bmNocaseCtxWrapper(uint8_t *text, uint8_t *needle, int times) { uint8_t *Bs2bmNocaseCtxWrapper(uint8_t *text, uint8_t *needle, int times)
{
uint32_t textlen = strlen((char *)text); uint32_t textlen = strlen((char *)text);
uint16_t needlelen = strlen((char *)needle); uint16_t needlelen = strlen((char *)needle);
@ -360,7 +374,8 @@ uint8_t *Bs2bmNocaseCtxWrapper(uint8_t *text, uint8_t *needle, int times) {
return ret; return ret;
} }
uint8_t *BoyerMooreCtxWrapper(uint8_t *text, uint8_t *needle, int times) { uint8_t *BoyerMooreCtxWrapper(uint8_t *text, uint8_t *needle, int times)
{
uint32_t textlen = strlen((char *)text); uint32_t textlen = strlen((char *)text);
uint16_t needlelen = strlen((char *)needle); uint16_t needlelen = strlen((char *)needle);
@ -386,7 +401,8 @@ uint8_t *BoyerMooreCtxWrapper(uint8_t *text, uint8_t *needle, int times) {
return ret; return ret;
} }
uint8_t *RawCtxWrapper(uint8_t *text, uint8_t *needle, int times) { uint8_t *RawCtxWrapper(uint8_t *text, uint8_t *needle, int times)
{
uint32_t textlen = strlen((char *)text); uint32_t textlen = strlen((char *)text);
uint16_t needlelen = strlen((char *)needle); uint16_t needlelen = strlen((char *)needle);
@ -402,7 +418,8 @@ uint8_t *RawCtxWrapper(uint8_t *text, uint8_t *needle, int times) {
return ret; return ret;
} }
uint8_t *BoyerMooreNocaseCtxWrapper(uint8_t *text, uint8_t *needle, int times) { uint8_t *BoyerMooreNocaseCtxWrapper(uint8_t *text, uint8_t *needle, int times)
{
uint32_t textlen = strlen((char *)text); uint32_t textlen = strlen((char *)text);
uint16_t needlelen = strlen((char *)needle); uint16_t needlelen = strlen((char *)needle);
@ -431,7 +448,8 @@ uint8_t *BoyerMooreNocaseCtxWrapper(uint8_t *text, uint8_t *needle, int times) {
/** /**
* \test Generic test for BasicSearch matching * \test Generic test for BasicSearch matching
*/ */
int UtilSpmBasicSearchTest01() { int UtilSpmBasicSearchTest01()
{
uint8_t *needle = (uint8_t *)"oPqRsT"; uint8_t *needle = (uint8_t *)"oPqRsT";
uint8_t *text = (uint8_t *)"aBcDeFgHiJkLmNoPqRsTuVwXyZ"; uint8_t *text = (uint8_t *)"aBcDeFgHiJkLmNoPqRsTuVwXyZ";
uint8_t *found = BasicSearchWrapper(text, needle, 1); uint8_t *found = BasicSearchWrapper(text, needle, 1);
@ -445,7 +463,8 @@ int UtilSpmBasicSearchTest01() {
/** /**
* \test Generic test for BasicSearch nocase matching * \test Generic test for BasicSearch nocase matching
*/ */
int UtilSpmBasicSearchNocaseTest01() { int UtilSpmBasicSearchNocaseTest01()
{
uint8_t *needle = (uint8_t *)"OpQrSt"; uint8_t *needle = (uint8_t *)"OpQrSt";
uint8_t *text = (uint8_t *)"aBcDeFgHiJkLmNoPqRsTuVwXyZ"; uint8_t *text = (uint8_t *)"aBcDeFgHiJkLmNoPqRsTuVwXyZ";
uint8_t *found = BasicSearchNocaseWrapper(text, needle, 1); uint8_t *found = BasicSearchNocaseWrapper(text, needle, 1);
@ -459,7 +478,8 @@ int UtilSpmBasicSearchNocaseTest01() {
/** /**
* \test Generic test for Bs2Bm matching * \test Generic test for Bs2Bm matching
*/ */
int UtilSpmBs2bmSearchTest01() { int UtilSpmBs2bmSearchTest01()
{
uint8_t *needle = (uint8_t *)"oPqRsT"; uint8_t *needle = (uint8_t *)"oPqRsT";
uint8_t *text = (uint8_t *)"aBcDeFgHiJkLmNoPqRsTuVwXyZ"; uint8_t *text = (uint8_t *)"aBcDeFgHiJkLmNoPqRsTuVwXyZ";
uint8_t *found = Bs2bmWrapper(text, needle, 1); uint8_t *found = Bs2bmWrapper(text, needle, 1);
@ -473,7 +493,8 @@ int UtilSpmBs2bmSearchTest01() {
/** /**
* \test Generic test for Bs2Bm no case matching * \test Generic test for Bs2Bm no case matching
*/ */
int UtilSpmBs2bmSearchNocaseTest01() { int UtilSpmBs2bmSearchNocaseTest01()
{
uint8_t *needle = (uint8_t *)"OpQrSt"; uint8_t *needle = (uint8_t *)"OpQrSt";
uint8_t *text = (uint8_t *)"aBcDeFgHiJkLmNoPqRsTuVwXyZ"; uint8_t *text = (uint8_t *)"aBcDeFgHiJkLmNoPqRsTuVwXyZ";
uint8_t *found = Bs2bmNocaseWrapper(text, needle, 1); uint8_t *found = Bs2bmNocaseWrapper(text, needle, 1);
@ -487,7 +508,8 @@ int UtilSpmBs2bmSearchNocaseTest01() {
/** /**
* \test Generic test for boyer moore matching * \test Generic test for boyer moore matching
*/ */
int UtilSpmBoyerMooreSearchTest01() { int UtilSpmBoyerMooreSearchTest01()
{
uint8_t *needle = (uint8_t *)"oPqRsT"; uint8_t *needle = (uint8_t *)"oPqRsT";
uint8_t *text = (uint8_t *)"aBcDeFgHiJkLmNoPqRsTuVwXyZ"; uint8_t *text = (uint8_t *)"aBcDeFgHiJkLmNoPqRsTuVwXyZ";
uint8_t *found = BoyerMooreWrapper(text, needle, 1); uint8_t *found = BoyerMooreWrapper(text, needle, 1);
@ -501,7 +523,8 @@ int UtilSpmBoyerMooreSearchTest01() {
/** /**
* \test Generic test for boyer moore nocase matching * \test Generic test for boyer moore nocase matching
*/ */
int UtilSpmBoyerMooreSearchNocaseTest01() { int UtilSpmBoyerMooreSearchNocaseTest01()
{
uint8_t *needle = (uint8_t *)"OpQrSt"; uint8_t *needle = (uint8_t *)"OpQrSt";
uint8_t *text = (uint8_t *)"aBcDeFgHiJkLmNoPqRsTuVwXyZ"; uint8_t *text = (uint8_t *)"aBcDeFgHiJkLmNoPqRsTuVwXyZ";
uint8_t *found = BoyerMooreNocaseWrapper(text, needle, 1); uint8_t *found = BoyerMooreNocaseWrapper(text, needle, 1);
@ -516,7 +539,8 @@ int UtilSpmBoyerMooreSearchNocaseTest01() {
* \test issue 130 (@redmine) check to ensure that the * \test issue 130 (@redmine) check to ensure that the
* problem is not the algorithm implementation * problem is not the algorithm implementation
*/ */
int UtilSpmBoyerMooreSearchNocaseTestIssue130() { int UtilSpmBoyerMooreSearchNocaseTestIssue130()
{
uint8_t *needle = (uint8_t *)"WWW-Authenticate: "; uint8_t *needle = (uint8_t *)"WWW-Authenticate: ";
uint8_t *text = (uint8_t *)"Date: Mon, 23 Feb 2009 13:31:49 GMT" uint8_t *text = (uint8_t *)"Date: Mon, 23 Feb 2009 13:31:49 GMT"
"Server: Apache\r\n" "Server: Apache\r\n"
@ -536,7 +560,8 @@ int UtilSpmBoyerMooreSearchNocaseTestIssue130() {
} }
/* Generic tests that should not match */ /* Generic tests that should not match */
int UtilSpmBasicSearchTest02() { int UtilSpmBasicSearchTest02()
{
uint8_t *needle = (uint8_t *)"oPQRsT"; uint8_t *needle = (uint8_t *)"oPQRsT";
uint8_t *text = (uint8_t *)"aBcDeFgHiJkLmNoPqRsTuVwXyZ"; uint8_t *text = (uint8_t *)"aBcDeFgHiJkLmNoPqRsTuVwXyZ";
uint8_t *found = BasicSearchWrapper(text, needle, 1); uint8_t *found = BasicSearchWrapper(text, needle, 1);
@ -547,7 +572,8 @@ int UtilSpmBasicSearchTest02() {
return 1; return 1;
} }
int UtilSpmBasicSearchNocaseTest02() { int UtilSpmBasicSearchNocaseTest02()
{
uint8_t *needle = (uint8_t *)"OpZrSt"; uint8_t *needle = (uint8_t *)"OpZrSt";
uint8_t *text = (uint8_t *)"aBcDeFgHiJkLmNoPqRsTuVwXyZ"; uint8_t *text = (uint8_t *)"aBcDeFgHiJkLmNoPqRsTuVwXyZ";
uint8_t *found = BasicSearchNocaseWrapper(text, needle, 1); uint8_t *found = BasicSearchNocaseWrapper(text, needle, 1);
@ -558,7 +584,8 @@ int UtilSpmBasicSearchNocaseTest02() {
return 1; return 1;
} }
int UtilSpmBs2bmSearchTest02() { int UtilSpmBs2bmSearchTest02()
{
uint8_t *needle = (uint8_t *)"oPQRsT"; uint8_t *needle = (uint8_t *)"oPQRsT";
uint8_t *text = (uint8_t *)"aBcDeFgHiJkLmNoPqRsTuVwXyZ"; uint8_t *text = (uint8_t *)"aBcDeFgHiJkLmNoPqRsTuVwXyZ";
uint8_t *found = Bs2bmWrapper(text, needle, 1); uint8_t *found = Bs2bmWrapper(text, needle, 1);
@ -569,7 +596,8 @@ int UtilSpmBs2bmSearchTest02() {
return 1; return 1;
} }
int UtilSpmBs2bmSearchNocaseTest02() { int UtilSpmBs2bmSearchNocaseTest02()
{
uint8_t *needle = (uint8_t *)"OpZrSt"; uint8_t *needle = (uint8_t *)"OpZrSt";
uint8_t *text = (uint8_t *)"aBcDeFgHiJkLmNoPqRsTuVwXyZ"; uint8_t *text = (uint8_t *)"aBcDeFgHiJkLmNoPqRsTuVwXyZ";
uint8_t *found = Bs2bmNocaseWrapper(text, needle, 1); uint8_t *found = Bs2bmNocaseWrapper(text, needle, 1);
@ -580,7 +608,8 @@ int UtilSpmBs2bmSearchNocaseTest02() {
return 1; return 1;
} }
int UtilSpmBoyerMooreSearchTest02() { int UtilSpmBoyerMooreSearchTest02()
{
uint8_t *needle = (uint8_t *)"oPQRsT"; uint8_t *needle = (uint8_t *)"oPQRsT";
uint8_t *text = (uint8_t *)"aBcDeFgHiJkLmNoPqRsTuVwXyZ"; uint8_t *text = (uint8_t *)"aBcDeFgHiJkLmNoPqRsTuVwXyZ";
uint8_t *found = BoyerMooreWrapper(text, needle, 1); uint8_t *found = BoyerMooreWrapper(text, needle, 1);
@ -591,7 +620,8 @@ int UtilSpmBoyerMooreSearchTest02() {
return 1; return 1;
} }
int UtilSpmBoyerMooreSearchNocaseTest02() { int UtilSpmBoyerMooreSearchNocaseTest02()
{
uint8_t *needle = (uint8_t *)"OpZrSt"; uint8_t *needle = (uint8_t *)"OpZrSt";
uint8_t *text = (uint8_t *)"aBcDeFgHiJkLmNoPqRsTuVwXyZ"; uint8_t *text = (uint8_t *)"aBcDeFgHiJkLmNoPqRsTuVwXyZ";
uint8_t *found = BoyerMooreNocaseWrapper(text, needle, 1); uint8_t *found = BoyerMooreNocaseWrapper(text, needle, 1);
@ -605,7 +635,8 @@ int UtilSpmBoyerMooreSearchNocaseTest02() {
/** /**
* \test Check that all the algorithms work at any offset and any pattern length * \test Check that all the algorithms work at any offset and any pattern length
*/ */
int UtilSpmSearchOffsetsTest01() { int UtilSpmSearchOffsetsTest01()
{
char *text[26][27]; char *text[26][27];
text[0][0]="azzzzzzzzzzzzzzzzzzzzzzzzzz"; text[0][0]="azzzzzzzzzzzzzzzzzzzzzzzzzz";
text[0][1]="zazzzzzzzzzzzzzzzzzzzzzzzzz"; text[0][1]="zazzzzzzzzzzzzzzzzzzzzzzzzz";
@ -1040,7 +1071,8 @@ int UtilSpmSearchOffsetsTest01() {
/** /**
* \test Check that all the algorithms (no case) work at any offset and any pattern length * \test Check that all the algorithms (no case) work at any offset and any pattern length
*/ */
int UtilSpmSearchOffsetsNocaseTest01() { int UtilSpmSearchOffsetsNocaseTest01()
{
char *text[26][27]; char *text[26][27];
text[0][0]="azzzzzzzzzzzzzzzzzzzzzzzzzz"; text[0][0]="azzzzzzzzzzzzzzzzzzzzzzzzzz";
text[0][1]="zazzzzzzzzzzzzzzzzzzzzzzzzz"; text[0][1]="zazzzzzzzzzzzzzzzzzzzzzzzzz";
@ -1475,7 +1507,8 @@ int UtilSpmSearchOffsetsNocaseTest01() {
/** /**
* \test Give some stats * \test Give some stats
*/ */
int UtilSpmSearchStatsTest01() { int UtilSpmSearchStatsTest01()
{
char *text[16]; char *text[16];
text[0]="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzza"; text[0]="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzza";
text[1]="aaaaaaaaazaaaaaaaaaaaaaaaaaaaaazaaaaaaaaaaaaaazaaaaaaaaaaaaaaaaaaaaazaaaaaaaaaaaaaaaaaaazaaaaaaaaaaaaaaaaaaazaaaaaaaaazaaaaaaaaaazaaaaaaaaaaaaazaaaaaaaaazaaaaaaaaaaaaaaaaazaaaaaaaaaaaaaaaaazaaaaaaaaazaaaaaaaaaazaaaaaraaaaazaaaaaaazaaaaaaaaaaaaaazaaaaaaaazaaaaaaaaazaaaaaaaaaaaaB"; text[1]="aaaaaaaaazaaaaaaaaaaaaaaaaaaaaazaaaaaaaaaaaaaazaaaaaaaaaaaaaaaaaaaaazaaaaaaaaaaaaaaaaaaazaaaaaaaaaaaaaaaaaaazaaaaaaaaazaaaaaaaaaazaaaaaaaaaaaaazaaaaaaaaazaaaaaaaaaaaaaaaaazaaaaaaaaaaaaaaaaazaaaaaaaaazaaaaaaaaaazaaaaaraaaaazaaaaaaazaaaaaaaaaaaaaazaaaaaaaazaaaaaaaaazaaaaaaaaaaaaB";
@ -1542,7 +1575,8 @@ int UtilSpmSearchStatsTest01() {
/** /**
* \test Give some stats for * \test Give some stats for
*/ */
int UtilSpmSearchStatsTest02() { int UtilSpmSearchStatsTest02()
{
char *text[16]; char *text[16];
text[0]="zzzzzzzzzzzzzzzzzza"; text[0]="zzzzzzzzzzzzzzzzzza";
text[1]="zzzzzzzzzzzzzzzzzzaB"; text[1]="zzzzzzzzzzzzzzzzzzaB";
@ -1607,7 +1641,8 @@ int UtilSpmSearchStatsTest02() {
} }
int UtilSpmSearchStatsTest03() { int UtilSpmSearchStatsTest03()
{
char *text[16]; char *text[16];
text[0]="zzzzzza"; text[0]="zzzzzza";
text[1]="zzzzzzaB"; text[1]="zzzzzzaB";
@ -1674,7 +1709,8 @@ int UtilSpmSearchStatsTest03() {
/** /**
* \test Give some stats * \test Give some stats
*/ */
int UtilSpmSearchStatsTest04() { int UtilSpmSearchStatsTest04()
{
char *text[16]; char *text[16];
text[0]="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzza"; text[0]="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzza";
text[1]="aaaaaaaaazaaaaaaaaaaaaaaaaaaaaazaaaaaaaaaaaaaazaaaaaaaaaaaaaaaaaaaaazaaaaaaaaaaaaaaaaaaazaaaaaaaaaaaaaaaaaaazaaaaaaaaazaaaaaaaaaazaaaaaaaaaaaaazaaaaaaaaazaaaaaaaaaaaaaaaaazaaaaaaaaaaaaaaaaazaaaaaaaaazaaaaaaaaaazaaaaaraaaaazaaaaaaazaaaaaaaaaaaaaazaaaaaaaazaaaaaaaaazaaaaaaaaaaaaB"; text[1]="aaaaaaaaazaaaaaaaaaaaaaaaaaaaaazaaaaaaaaaaaaaazaaaaaaaaaaaaaaaaaaaaazaaaaaaaaaaaaaaaaaaazaaaaaaaaaaaaaaaaaaazaaaaaaaaazaaaaaaaaaazaaaaaaaaaaaaazaaaaaaaaazaaaaaaaaaaaaaaaaazaaaaaaaaaaaaaaaaazaaaaaaaaazaaaaaaaaaazaaaaaraaaaazaaaaaaazaaaaaaaaaaaaaazaaaaaaaazaaaaaaaaazaaaaaaaaaaaaB";
@ -1748,7 +1784,8 @@ int UtilSpmSearchStatsTest04() {
/** /**
* \test Give some stats for * \test Give some stats for
*/ */
int UtilSpmSearchStatsTest05() { int UtilSpmSearchStatsTest05()
{
char *text[16]; char *text[16];
text[0]="zzzzzzzzzzzzzzzzzza"; text[0]="zzzzzzzzzzzzzzzzzza";
text[1]="zzzzzzzzzzzzzzzzzzaB"; text[1]="zzzzzzzzzzzzzzzzzzaB";
@ -1813,7 +1850,8 @@ int UtilSpmSearchStatsTest05() {
} }
int UtilSpmSearchStatsTest06() { int UtilSpmSearchStatsTest06()
{
char *text[16]; char *text[16];
text[0]="zzzzkzzzzzzzkzzzzzza"; text[0]="zzzzkzzzzzzzkzzzzzza";
text[1]="BBBBkBBBBBBBkBBBBBaB"; text[1]="BBBBkBBBBBBBkBBBBBaB";
@ -1855,7 +1893,8 @@ int UtilSpmSearchStatsTest06() {
return 1; return 1;
} }
int UtilSpmSearchStatsTest07() { int UtilSpmSearchStatsTest07()
{
char *text[16]; char *text[16];
text[0]="zzzza"; text[0]="zzzza";
text[1]="BBBaB"; text[1]="BBBaB";
@ -1900,7 +1939,8 @@ int UtilSpmSearchStatsTest07() {
/** /**
* \test Give some stats for no case algorithms * \test Give some stats for no case algorithms
*/ */
int UtilSpmNocaseSearchStatsTest01() { int UtilSpmNocaseSearchStatsTest01()
{
char *text[16]; char *text[16];
text[0]="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz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zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzaB";
@ -1964,7 +2004,8 @@ int UtilSpmNocaseSearchStatsTest01() {
return 1; return 1;
} }
int UtilSpmNocaseSearchStatsTest02() { int UtilSpmNocaseSearchStatsTest02()
{
char *text[16]; char *text[16];
text[0]="zzzzzzzzzzzzzzzzzza"; text[0]="zzzzzzzzzzzzzzzzzza";
text[1]="zzzzzzzzzzzzzzzzzzaB"; text[1]="zzzzzzzzzzzzzzzzzzaB";
@ -2029,7 +2070,8 @@ int UtilSpmNocaseSearchStatsTest02() {
} }
int UtilSpmNocaseSearchStatsTest03() { int UtilSpmNocaseSearchStatsTest03()
{
char *text[16]; char *text[16];
text[0]="zzzzkzzzzzzzkzzzzzza"; text[0]="zzzzkzzzzzzzkzzzzzza";
text[1]="BBBBkBBBBBBBkBBBBBaB"; text[1]="BBBBkBBBBBBBkBBBBBaB";
@ -2074,7 +2116,8 @@ int UtilSpmNocaseSearchStatsTest03() {
/** /**
* \test Give some stats for no case algorithms * \test Give some stats for no case algorithms
*/ */
int UtilSpmNocaseSearchStatsTest04() { int UtilSpmNocaseSearchStatsTest04()
{
char *text[16]; char *text[16];
text[0]="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz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mNocaseSearchStatsTest05()
{
char *text[16]; char *text[16];
text[0]="zzzzzzzzzzzzzzzzzza"; text[0]="zzzzzzzzzzzzzzzzzza";
text[1]="zzzzzzzzzzzzzzzzzzaB"; text[1]="zzzzzzzzzzzzzzzzzzaB";
@ -2203,7 +2247,8 @@ int UtilSpmNocaseSearchStatsTest05() {
} }
int UtilSpmNocaseSearchStatsTest06() { int UtilSpmNocaseSearchStatsTest06()
{
char *text[16]; char *text[16];
text[0]="zzzzkzzzzzzzkzzzzzza"; text[0]="zzzzkzzzzzzzkzzzzzza";
text[1]="BBBBkBBBBBBBkBBBBBaB"; text[1]="BBBBkBBBBBBBkBBBBBaB";
@ -2245,7 +2290,8 @@ int UtilSpmNocaseSearchStatsTest06() {
return 1; return 1;
} }
int UtilSpmNocaseSearchStatsTest07() { int UtilSpmNocaseSearchStatsTest07()
{
char *text[16]; char *text[16];
text[0]="zzzza"; text[0]="zzzza";
text[1]="bbbAb"; text[1]="bbbAb";

@ -47,7 +47,8 @@ static int storage_max_id[STORAGE_MAX];
static int storage_registraton_closed = 0; static int storage_registraton_closed = 0;
static StorageMapping **storage_map = NULL; static StorageMapping **storage_map = NULL;
const char *StoragePrintType(StorageEnum type) { const char *StoragePrintType(StorageEnum type)
{
switch(type) { switch(type) {
case STORAGE_HOST: case STORAGE_HOST:
return "host"; return "host";
@ -59,14 +60,16 @@ const char *StoragePrintType(StorageEnum type) {
return "invalid"; return "invalid";
} }
void StorageInit(void) { void StorageInit(void)
{
memset(&storage_max_id, 0x00, sizeof(storage_max_id)); memset(&storage_max_id, 0x00, sizeof(storage_max_id));
storage_list = NULL; storage_list = NULL;
storage_map = NULL; storage_map = NULL;
storage_registraton_closed = 0; storage_registraton_closed = 0;
} }
void StorageCleanup(void) { void StorageCleanup(void)
{
if (storage_map) { if (storage_map) {
int i; int i;
for (i = 0; i < STORAGE_MAX; i++) { for (i = 0; i < STORAGE_MAX; i++) {
@ -89,7 +92,8 @@ void StorageCleanup(void) {
storage_list = NULL; storage_list = NULL;
} }
int StorageRegister(const StorageEnum type, const char *name, const unsigned int size, void *(*Alloc)(unsigned int), void (*Free)(void *)) { int StorageRegister(const StorageEnum type, const char *name, const unsigned int size, void *(*Alloc)(unsigned int), void (*Free)(void *))
{
if (storage_registraton_closed) if (storage_registraton_closed)
return -1; return -1;
@ -128,7 +132,8 @@ int StorageRegister(const StorageEnum type, const char *name, const unsigned int
return entry->id; return entry->id;
} }
int StorageFinalize(void) { int StorageFinalize(void)
{
int count = 0; int count = 0;
int i; int i;
@ -185,7 +190,8 @@ int StorageFinalize(void) {
return 0; return 0;
} }
unsigned int StorageGetCnt(StorageEnum type) { unsigned int StorageGetCnt(StorageEnum type)
{
return storage_max_id[type]; return storage_max_id[type];
} }
@ -195,11 +201,13 @@ unsigned int StorageGetCnt(StorageEnum type) {
* *
* \todo we could return -1 when registration isn't closed yet, however * \todo we could return -1 when registration isn't closed yet, however
* this will break lots of tests currently, so not doing it now */ * this will break lots of tests currently, so not doing it now */
unsigned int StorageGetSize(StorageEnum type) { unsigned int StorageGetSize(StorageEnum type)
{
return storage_max_id[type] * sizeof(void *); return storage_max_id[type] * sizeof(void *);
} }
void *StorageGetById(const Storage *storage, const StorageEnum type, const int id) { void *StorageGetById(const Storage *storage, const StorageEnum type, const int id)
{
#ifdef DEBUG #ifdef DEBUG
BUG_ON(!storage_registraton_closed); BUG_ON(!storage_registraton_closed);
#endif #endif
@ -209,7 +217,8 @@ void *StorageGetById(const Storage *storage, const StorageEnum type, const int i
return storage[id]; return storage[id];
} }
int StorageSetById(Storage *storage, const StorageEnum type, const int id, void *ptr) { int StorageSetById(Storage *storage, const StorageEnum type, const int id, void *ptr)
{
#ifdef DEBUG #ifdef DEBUG
BUG_ON(!storage_registraton_closed); BUG_ON(!storage_registraton_closed);
#endif #endif
@ -220,7 +229,8 @@ int StorageSetById(Storage *storage, const StorageEnum type, const int id, void
return 0; return 0;
} }
void *StorageAllocByIdPrealloc(Storage *storage, StorageEnum type, int id) { void *StorageAllocByIdPrealloc(Storage *storage, StorageEnum type, int id)
{
#ifdef DEBUG #ifdef DEBUG
BUG_ON(!storage_registraton_closed); BUG_ON(!storage_registraton_closed);
#endif #endif
@ -237,7 +247,8 @@ void *StorageAllocByIdPrealloc(Storage *storage, StorageEnum type, int id) {
return storage[id]; return storage[id];
} }
void *StorageAllocById(Storage **storage, StorageEnum type, int id) { void *StorageAllocById(Storage **storage, StorageEnum type, int id)
{
#ifdef DEBUG #ifdef DEBUG
BUG_ON(!storage_registraton_closed); BUG_ON(!storage_registraton_closed);
#endif #endif
@ -266,7 +277,8 @@ void *StorageAllocById(Storage **storage, StorageEnum type, int id) {
return store[id]; return store[id];
} }
void StorageFreeById(Storage *storage, StorageEnum type, int id) { void StorageFreeById(Storage *storage, StorageEnum type, int id)
{
#ifdef DEBUG #ifdef DEBUG
BUG_ON(!storage_registraton_closed); BUG_ON(!storage_registraton_closed);
#endif #endif
@ -283,7 +295,8 @@ void StorageFreeById(Storage *storage, StorageEnum type, int id) {
} }
} }
void StorageFreeAll(Storage *storage, StorageEnum type) { void StorageFreeAll(Storage *storage, StorageEnum type)
{
if (*storage == NULL) if (*storage == NULL)
return; return;
@ -302,7 +315,8 @@ void StorageFreeAll(Storage *storage, StorageEnum type) {
} }
} }
void StorageFree(Storage **storage, StorageEnum type) { void StorageFree(Storage **storage, StorageEnum type)
{
if (*storage == NULL) if (*storage == NULL)
return; return;
@ -325,16 +339,19 @@ void StorageFree(Storage **storage, StorageEnum type) {
#ifdef UNITTESTS #ifdef UNITTESTS
static void *StorageTestAlloc(unsigned int size) { static void *StorageTestAlloc(unsigned int size)
{
void *x = SCMalloc(size); void *x = SCMalloc(size);
return x; return x;
} }
static void StorageTestFree(void *x) { static void StorageTestFree(void *x)
{
if (x) if (x)
SCFree(x); SCFree(x);
} }
static int StorageTest01(void) { static int StorageTest01(void)
{
StorageInit(); StorageInit();
int id = StorageRegister(STORAGE_HOST, "test", 8, StorageTestAlloc, StorageTestFree); int id = StorageRegister(STORAGE_HOST, "test", 8, StorageTestAlloc, StorageTestFree);
@ -361,14 +378,16 @@ struct StorageTest02Data {
int abc; int abc;
}; };
static void *StorageTest02Init(unsigned int size) { static void *StorageTest02Init(unsigned int size)
{
struct StorageTest02Data *data = (struct StorageTest02Data *)SCMalloc(size); struct StorageTest02Data *data = (struct StorageTest02Data *)SCMalloc(size);
if (data != NULL) if (data != NULL)
data->abc = 1234; data->abc = 1234;
return (void *)data; return (void *)data;
} }
static int StorageTest02(void) { static int StorageTest02(void)
{
struct StorageTest02Data *test = NULL; struct StorageTest02Data *test = NULL;
StorageInit(); StorageInit();
@ -436,7 +455,8 @@ error:
return 0; return 0;
} }
static int StorageTest03(void) { static int StorageTest03(void)
{
StorageInit(); StorageInit();
int id = StorageRegister(STORAGE_HOST, "test", 8, StorageTestAlloc, StorageTestFree); int id = StorageRegister(STORAGE_HOST, "test", 8, StorageTestAlloc, StorageTestFree);
@ -503,7 +523,8 @@ error:
return 0; return 0;
} }
void StorageRegisterTests(void) { void StorageRegisterTests(void)
{
UtRegisterTest("StorageTest01", StorageTest01, 1); UtRegisterTest("StorageTest01", StorageTest01, 1);
UtRegisterTest("StorageTest02", StorageTest02, 1); UtRegisterTest("StorageTest02", StorageTest02, 1);
UtRegisterTest("StorageTest03", StorageTest03, 1); UtRegisterTest("StorageTest03", StorageTest03, 1);

@ -1,4 +1,4 @@
/* Copyright (C) 2007-2010 Open Information Security Foundation /* Copyright (C) 2007-2013 Open Information Security Foundation
* *
* You can copy, redistribute or modify this Program under the terms of * You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free * the GNU General Public License version 2 as published by the Free
@ -53,7 +53,8 @@ SCEnumCharMap sc_syslog_facility_map[] = {
}; };
/** \brief returns the syslog facility enum map */ /** \brief returns the syslog facility enum map */
SCEnumCharMap *SCSyslogGetFacilityMap() { SCEnumCharMap *SCSyslogGetFacilityMap()
{
return sc_syslog_facility_map; return sc_syslog_facility_map;
} }
@ -70,7 +71,8 @@ SCEnumCharMap sc_syslog_level_map[ ] = {
}; };
/** \brief returns the syslog facility enum map */ /** \brief returns the syslog facility enum map */
SCEnumCharMap *SCSyslogGetLogLevelMap() { SCEnumCharMap *SCSyslogGetLogLevelMap()
{
return sc_syslog_level_map; return sc_syslog_level_map;
} }

@ -43,7 +43,8 @@ void TimeInit(void)
tzset(); tzset();
} }
void TimeDeinit(void) { void TimeDeinit(void)
{
SCSpinDestroy(&current_time_spinlock); SCSpinDestroy(&current_time_spinlock);
} }
@ -78,7 +79,8 @@ void TimeSet(struct timeval *tv)
} }
/** \brief set the time to "gettimeofday" meant for testing */ /** \brief set the time to "gettimeofday" meant for testing */
void TimeSetToCurrentTime(void) { void TimeSetToCurrentTime(void)
{
struct timeval tv; struct timeval tv;
memset(&tv, 0x00, sizeof(tv)); memset(&tv, 0x00, sizeof(tv));
@ -107,7 +109,8 @@ void TimeGet(struct timeval *tv)
/** \brief increment the time in the engine /** \brief increment the time in the engine
* \param tv_sec seconds to increment the time with */ * \param tv_sec seconds to increment the time with */
void TimeSetIncrementTime(uint32_t tv_sec) { void TimeSetIncrementTime(uint32_t tv_sec)
{
struct timeval tv; struct timeval tv;
memset(&tv, 0x00, sizeof(tv)); memset(&tv, 0x00, sizeof(tv));
TimeGet(&tv); TimeGet(&tv);

@ -1,4 +1,4 @@
/* Copyright (C) 2007-2010 Open Information Security Foundation /* Copyright (C) 2007-2013 Open Information Security Foundation
* *
* You can copy, redistribute or modify this Program under the terms of * You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free * the GNU General Public License version 2 as published by the Free
@ -34,7 +34,8 @@
#include "util-debug.h" #include "util-debug.h"
void GenericVarFree(GenericVar *gv) { void GenericVarFree(GenericVar *gv)
{
if (gv == NULL) if (gv == NULL)
return; return;
@ -71,7 +72,8 @@ void GenericVarFree(GenericVar *gv) {
GenericVarFree(next_gv); GenericVarFree(next_gv);
} }
void GenericVarAppend(GenericVar **list, GenericVar *gv) { void GenericVarAppend(GenericVar **list, GenericVar *gv)
{
gv->next = NULL; gv->next = NULL;
if (*list == NULL) { if (*list == NULL) {
@ -89,7 +91,8 @@ void GenericVarAppend(GenericVar **list, GenericVar *gv) {
} }
} }
void GenericVarRemove(GenericVar **list, GenericVar *gv) { void GenericVarRemove(GenericVar **list, GenericVar *gv)
{
if (*list == NULL) if (*list == NULL)
return; return;
@ -108,4 +111,3 @@ void GenericVarRemove(GenericVar **list, GenericVar *gv) {
listgv = listgv->next; listgv = listgv->next;
} }
} }

Loading…
Cancel
Save