From: Victor Julien Date: Thu, 29 Nov 2018 06:08:12 +0000 (+0100) Subject: detect/http_raw_header: minor code cleanups X-Git-Tag: suricata-5.0.0-beta1~253 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c2984129479dd309fc64670b7f510a421c4c57fd;p=thirdparty%2Fsuricata.git detect/http_raw_header: minor code cleanups --- diff --git a/src/detect-engine-hrhd.c b/src/detect-engine-hrhd.c index c515408063..4836ec7a20 100644 --- a/src/detect-engine-hrhd.c +++ b/src/detect-engine-hrhd.c @@ -305,10 +305,6 @@ static int DetectEngineHttpRawHeaderTest01(void) end: if (alp_tctx != NULL) AppLayerParserThreadCtxFree(alp_tctx); - if (de_ctx != NULL) - SigGroupCleanup(de_ctx); - if (de_ctx != NULL) - SigCleanSignatures(de_ctx); if (de_ctx != NULL) DetectEngineCtxFree(de_ctx); @@ -402,10 +398,6 @@ static int DetectEngineHttpRawHeaderTest02(void) end: if (alp_tctx != NULL) AppLayerParserThreadCtxFree(alp_tctx); - if (de_ctx != NULL) - SigGroupCleanup(de_ctx); - if (de_ctx != NULL) - SigCleanSignatures(de_ctx); if (de_ctx != NULL) DetectEngineCtxFree(de_ctx); @@ -499,10 +491,6 @@ static int DetectEngineHttpRawHeaderTest03(void) end: if (alp_tctx != NULL) AppLayerParserThreadCtxFree(alp_tctx); - if (de_ctx != NULL) - SigGroupCleanup(de_ctx); - if (de_ctx != NULL) - SigCleanSignatures(de_ctx); if (de_ctx != NULL) DetectEngineCtxFree(de_ctx); @@ -596,10 +584,6 @@ static int DetectEngineHttpRawHeaderTest04(void) end: if (alp_tctx != NULL) AppLayerParserThreadCtxFree(alp_tctx); - if (de_ctx != NULL) - SigGroupCleanup(de_ctx); - if (de_ctx != NULL) - SigCleanSignatures(de_ctx); if (de_ctx != NULL) DetectEngineCtxFree(de_ctx); @@ -693,10 +677,6 @@ static int DetectEngineHttpRawHeaderTest05(void) end: if (alp_tctx != NULL) AppLayerParserThreadCtxFree(alp_tctx); - if (de_ctx != NULL) - SigGroupCleanup(de_ctx); - if (de_ctx != NULL) - SigCleanSignatures(de_ctx); if (de_ctx != NULL) DetectEngineCtxFree(de_ctx); @@ -790,10 +770,6 @@ static int DetectEngineHttpRawHeaderTest06(void) end: if (alp_tctx != NULL) AppLayerParserThreadCtxFree(alp_tctx); - if (de_ctx != NULL) - SigGroupCleanup(de_ctx); - if (de_ctx != NULL) - SigCleanSignatures(de_ctx); if (de_ctx != NULL) DetectEngineCtxFree(de_ctx); @@ -887,10 +863,6 @@ static int DetectEngineHttpRawHeaderTest07(void) end: if (alp_tctx != NULL) AppLayerParserThreadCtxFree(alp_tctx); - if (de_ctx != NULL) - SigGroupCleanup(de_ctx); - if (de_ctx != NULL) - SigCleanSignatures(de_ctx); if (de_ctx != NULL) DetectEngineCtxFree(de_ctx); @@ -984,10 +956,6 @@ static int DetectEngineHttpRawHeaderTest08(void) end: if (alp_tctx != NULL) AppLayerParserThreadCtxFree(alp_tctx); - if (de_ctx != NULL) - SigGroupCleanup(de_ctx); - if (de_ctx != NULL) - SigCleanSignatures(de_ctx); if (de_ctx != NULL) DetectEngineCtxFree(de_ctx); @@ -1081,10 +1049,6 @@ static int DetectEngineHttpRawHeaderTest09(void) end: if (alp_tctx != NULL) AppLayerParserThreadCtxFree(alp_tctx); - if (de_ctx != NULL) - SigGroupCleanup(de_ctx); - if (de_ctx != NULL) - SigCleanSignatures(de_ctx); if (de_ctx != NULL) DetectEngineCtxFree(de_ctx); @@ -1178,10 +1142,6 @@ static int DetectEngineHttpRawHeaderTest10(void) end: if (alp_tctx != NULL) AppLayerParserThreadCtxFree(alp_tctx); - if (de_ctx != NULL) - SigGroupCleanup(de_ctx); - if (de_ctx != NULL) - SigCleanSignatures(de_ctx); if (de_ctx != NULL) DetectEngineCtxFree(de_ctx); @@ -1275,10 +1235,6 @@ static int DetectEngineHttpRawHeaderTest11(void) end: if (alp_tctx != NULL) AppLayerParserThreadCtxFree(alp_tctx); - if (de_ctx != NULL) - SigGroupCleanup(de_ctx); - if (de_ctx != NULL) - SigCleanSignatures(de_ctx); if (de_ctx != NULL) DetectEngineCtxFree(de_ctx); @@ -1372,10 +1328,6 @@ static int DetectEngineHttpRawHeaderTest12(void) end: if (alp_tctx != NULL) AppLayerParserThreadCtxFree(alp_tctx); - if (de_ctx != NULL) - SigGroupCleanup(de_ctx); - if (de_ctx != NULL) - SigCleanSignatures(de_ctx); if (de_ctx != NULL) DetectEngineCtxFree(de_ctx); @@ -1469,10 +1421,6 @@ static int DetectEngineHttpRawHeaderTest13(void) end: if (alp_tctx != NULL) AppLayerParserThreadCtxFree(alp_tctx); - if (de_ctx != NULL) - SigGroupCleanup(de_ctx); - if (de_ctx != NULL) - SigCleanSignatures(de_ctx); if (de_ctx != NULL) DetectEngineCtxFree(de_ctx); @@ -1566,10 +1514,6 @@ static int DetectEngineHttpRawHeaderTest14(void) end: if (alp_tctx != NULL) AppLayerParserThreadCtxFree(alp_tctx); - if (de_ctx != NULL) - SigGroupCleanup(de_ctx); - if (de_ctx != NULL) - SigCleanSignatures(de_ctx); if (de_ctx != NULL) DetectEngineCtxFree(de_ctx); @@ -1663,10 +1607,6 @@ static int DetectEngineHttpRawHeaderTest15(void) end: if (alp_tctx != NULL) AppLayerParserThreadCtxFree(alp_tctx); - if (de_ctx != NULL) - SigGroupCleanup(de_ctx); - if (de_ctx != NULL) - SigCleanSignatures(de_ctx); if (de_ctx != NULL) DetectEngineCtxFree(de_ctx); @@ -1760,10 +1700,6 @@ static int DetectEngineHttpRawHeaderTest16(void) end: if (alp_tctx != NULL) AppLayerParserThreadCtxFree(alp_tctx); - if (de_ctx != NULL) - SigGroupCleanup(de_ctx); - if (de_ctx != NULL) - SigCleanSignatures(de_ctx); if (de_ctx != NULL) DetectEngineCtxFree(de_ctx); @@ -1857,10 +1793,6 @@ static int DetectEngineHttpRawHeaderTest17(void) end: if (alp_tctx != NULL) AppLayerParserThreadCtxFree(alp_tctx); - if (de_ctx != NULL) - SigGroupCleanup(de_ctx); - if (de_ctx != NULL) - SigCleanSignatures(de_ctx); if (de_ctx != NULL) DetectEngineCtxFree(de_ctx); @@ -1982,10 +1914,6 @@ static int DetectEngineHttpRawHeaderTest20(void) end: if (alp_tctx != NULL) AppLayerParserThreadCtxFree(alp_tctx); - if (de_ctx != NULL) - SigGroupCleanup(de_ctx); - if (de_ctx != NULL) - SigCleanSignatures(de_ctx); if (de_ctx != NULL) DetectEngineCtxFree(de_ctx); @@ -2108,10 +2036,6 @@ static int DetectEngineHttpRawHeaderTest21(void) end: if (alp_tctx != NULL) AppLayerParserThreadCtxFree(alp_tctx); - if (de_ctx != NULL) - SigGroupCleanup(de_ctx); - if (de_ctx != NULL) - SigCleanSignatures(de_ctx); if (de_ctx != NULL) DetectEngineCtxFree(de_ctx); @@ -2234,10 +2158,6 @@ static int DetectEngineHttpRawHeaderTest22(void) end: if (alp_tctx != NULL) AppLayerParserThreadCtxFree(alp_tctx); - if (de_ctx != NULL) - SigGroupCleanup(de_ctx); - if (de_ctx != NULL) - SigCleanSignatures(de_ctx); if (de_ctx != NULL) DetectEngineCtxFree(de_ctx); @@ -2360,10 +2280,6 @@ static int DetectEngineHttpRawHeaderTest23(void) end: if (alp_tctx != NULL) AppLayerParserThreadCtxFree(alp_tctx); - if (de_ctx != NULL) - SigGroupCleanup(de_ctx); - if (de_ctx != NULL) - SigCleanSignatures(de_ctx); if (de_ctx != NULL) DetectEngineCtxFree(de_ctx); @@ -2486,10 +2402,6 @@ static int DetectEngineHttpRawHeaderTest24(void) end: if (alp_tctx != NULL) AppLayerParserThreadCtxFree(alp_tctx); - if (de_ctx != NULL) - SigGroupCleanup(de_ctx); - if (de_ctx != NULL) - SigCleanSignatures(de_ctx); if (de_ctx != NULL) DetectEngineCtxFree(de_ctx); @@ -2612,10 +2524,6 @@ static int DetectEngineHttpRawHeaderTest25(void) end: if (alp_tctx != NULL) AppLayerParserThreadCtxFree(alp_tctx); - if (de_ctx != NULL) - SigGroupCleanup(de_ctx); - if (de_ctx != NULL) - SigCleanSignatures(de_ctx); if (de_ctx != NULL) DetectEngineCtxFree(de_ctx); @@ -2736,10 +2644,6 @@ static int DetectEngineHttpRawHeaderTest26(void) result = 1; end: - if (de_ctx != NULL) - SigGroupCleanup(de_ctx); - if (de_ctx != NULL) - SigCleanSignatures(de_ctx); if (de_ctx != NULL) DetectEngineCtxFree(de_ctx); @@ -2862,10 +2766,6 @@ static int DetectEngineHttpRawHeaderTest27(void) end: if (alp_tctx != NULL) AppLayerParserThreadCtxFree(alp_tctx); - if (de_ctx != NULL) - SigGroupCleanup(de_ctx); - if (de_ctx != NULL) - SigCleanSignatures(de_ctx); if (de_ctx != NULL) DetectEngineCtxFree(de_ctx); @@ -2992,10 +2892,6 @@ static int DetectEngineHttpRawHeaderTest28(void) end: if (alp_tctx != NULL) AppLayerParserThreadCtxFree(alp_tctx); - if (de_ctx != NULL) - SigGroupCleanup(de_ctx); - if (de_ctx != NULL) - SigCleanSignatures(de_ctx); if (de_ctx != NULL) DetectEngineCtxFree(de_ctx); @@ -3122,10 +3018,6 @@ static int DetectEngineHttpRawHeaderTest29(void) end: if (alp_tctx != NULL) AppLayerParserThreadCtxFree(alp_tctx); - if (de_ctx != NULL) - SigGroupCleanup(de_ctx); - if (de_ctx != NULL) - SigCleanSignatures(de_ctx); if (de_ctx != NULL) DetectEngineCtxFree(de_ctx); @@ -3260,10 +3152,6 @@ static int DetectEngineHttpRawHeaderTest31(void) end: if (alp_tctx != NULL) AppLayerParserThreadCtxFree(alp_tctx); - if (de_ctx != NULL) - SigGroupCleanup(de_ctx); - if (de_ctx != NULL) - SigCleanSignatures(de_ctx); if (de_ctx != NULL) DetectEngineCtxFree(de_ctx); @@ -3392,10 +3280,6 @@ static int DetectEngineHttpRawHeaderTest32(void) end: if (alp_tctx != NULL) AppLayerParserThreadCtxFree(alp_tctx); - if (de_ctx != NULL) - SigGroupCleanup(de_ctx); - if (de_ctx != NULL) - SigCleanSignatures(de_ctx); if (de_ctx != NULL) DetectEngineCtxFree(de_ctx); diff --git a/src/detect-http-raw-header.c b/src/detect-http-raw-header.c index 388a26a7ec..8269cb28a6 100644 --- a/src/detect-http-raw-header.c +++ b/src/detect-http-raw-header.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2007-2010 Open Information Security Foundation +/* Copyright (C) 2007-2018 Open Information Security Foundation * * You can copy, redistribute or modify this Program under the terms of * the GNU General Public License version 2 as published by the Free @@ -62,7 +62,6 @@ static int DetectHttpRawHeaderSetup(DetectEngineCtx *, Signature *, const char *); static void DetectHttpRawHeaderRegisterTests(void); -static void DetectHttpRawHeaderFree(void *); static _Bool DetectHttpRawHeaderValidateCallback(const Signature *s, const char **sigerror); static int g_http_raw_header_buffer_id = 0; @@ -72,9 +71,7 @@ static int g_http_raw_header_buffer_id = 0; void DetectHttpRawHeaderRegister(void) { sigmatch_table[DETECT_AL_HTTP_RAW_HEADER].name = "http_raw_header"; - sigmatch_table[DETECT_AL_HTTP_RAW_HEADER].Match = NULL; sigmatch_table[DETECT_AL_HTTP_RAW_HEADER].Setup = DetectHttpRawHeaderSetup; - sigmatch_table[DETECT_AL_HTTP_RAW_HEADER].Free = DetectHttpRawHeaderFree; sigmatch_table[DETECT_AL_HTTP_RAW_HEADER].RegisterTests = DetectHttpRawHeaderRegisterTests; sigmatch_table[DETECT_AL_HTTP_RAW_HEADER].flags |= SIGMATCH_NOOPT; @@ -100,25 +97,6 @@ void DetectHttpRawHeaderRegister(void) g_http_raw_header_buffer_id = DetectBufferTypeGetByName("http_raw_header"); } - -/** - * \brief this function clears the memory of http_raw_header modifier keyword - * - * \param ptr Pointer to the Detection Header Data - */ -void DetectHttpRawHeaderFree(void *ptr) -{ - DetectContentData *cd = (DetectContentData *)ptr; - if (cd == NULL) - return; - - if (cd->content != NULL) - SCFree(cd->content); - SCFree(cd); - - return; -} - /** * \brief The setup function for the http_raw_header keyword for a signature. * @@ -197,8 +175,6 @@ static int DetectHttpRawHeaderTest01(void) end: - SigGroupCleanup(de_ctx); - SigCleanSignatures(de_ctx); DetectEngineCtxFree(de_ctx); return result; @@ -227,8 +203,6 @@ static int DetectHttpRawHeaderTest02(void) printf("Error parsing signature: "); end: - SigGroupCleanup(de_ctx); - SigCleanSignatures(de_ctx); DetectEngineCtxFree(de_ctx); return result; @@ -257,8 +231,6 @@ static int DetectHttpRawHeaderTest03(void) printf("Error parsing signature: "); end: - SigGroupCleanup(de_ctx); - SigCleanSignatures(de_ctx); DetectEngineCtxFree(de_ctx); return result; @@ -287,8 +259,6 @@ static int DetectHttpRawHeaderTest04(void) printf("Error parsing signature: "); end: - SigGroupCleanup(de_ctx); - SigCleanSignatures(de_ctx); DetectEngineCtxFree(de_ctx); return result; @@ -317,8 +287,6 @@ static int DetectHttpRawHeaderTest05(void) printf("Error parsing signature: "); end: - SigGroupCleanup(de_ctx); - SigCleanSignatures(de_ctx); DetectEngineCtxFree(de_ctx); return result; @@ -413,10 +381,6 @@ static int DetectHttpRawHeaderTest06(void) end: if (alp_tctx != NULL) AppLayerParserThreadCtxFree(alp_tctx); - if (de_ctx != NULL) - SigGroupCleanup(de_ctx); - if (de_ctx != NULL) - SigCleanSignatures(de_ctx); if (de_ctx != NULL) DetectEngineCtxFree(de_ctx); @@ -542,10 +506,6 @@ static int DetectHttpRawHeaderTest07(void) end: if (alp_tctx != NULL) AppLayerParserThreadCtxFree(alp_tctx); - if (de_ctx != NULL) - SigGroupCleanup(de_ctx); - if (de_ctx != NULL) - SigCleanSignatures(de_ctx); if (de_ctx != NULL) DetectEngineCtxFree(de_ctx); @@ -671,10 +631,6 @@ static int DetectHttpRawHeaderTest08(void) end: if (alp_tctx != NULL) AppLayerParserThreadCtxFree(alp_tctx); - if (de_ctx != NULL) - SigGroupCleanup(de_ctx); - if (de_ctx != NULL) - SigCleanSignatures(de_ctx); if (de_ctx != NULL) DetectEngineCtxFree(de_ctx); @@ -801,10 +757,6 @@ static int DetectHttpRawHeaderTest09(void) end: if (alp_tctx != NULL) AppLayerParserThreadCtxFree(alp_tctx); - if (de_ctx != NULL) - SigGroupCleanup(de_ctx); - if (de_ctx != NULL) - SigCleanSignatures(de_ctx); if (de_ctx != NULL) DetectEngineCtxFree(de_ctx); @@ -931,10 +883,6 @@ static int DetectHttpRawHeaderTest10(void) end: if (alp_tctx != NULL) AppLayerParserThreadCtxFree(alp_tctx); - if (de_ctx != NULL) - SigGroupCleanup(de_ctx); - if (de_ctx != NULL) - SigCleanSignatures(de_ctx); if (de_ctx != NULL) DetectEngineCtxFree(de_ctx); @@ -1034,10 +982,6 @@ static int DetectHttpRawHeaderTest11(void) end: if (alp_tctx != NULL) AppLayerParserThreadCtxFree(alp_tctx); - if (de_ctx != NULL) - SigGroupCleanup(de_ctx); - if (de_ctx != NULL) - SigCleanSignatures(de_ctx); if (de_ctx != NULL) DetectEngineCtxFree(de_ctx); @@ -1136,10 +1080,6 @@ static int DetectHttpRawHeaderTest12(void) end: if (alp_tctx != NULL) AppLayerParserThreadCtxFree(alp_tctx); - if (de_ctx != NULL) - SigGroupCleanup(de_ctx); - if (de_ctx != NULL) - SigCleanSignatures(de_ctx); if (de_ctx != NULL) DetectEngineCtxFree(de_ctx); @@ -1240,10 +1180,6 @@ end: if (alp_tctx != NULL) AppLayerParserThreadCtxFree(alp_tctx); - if (de_ctx != NULL) - SigGroupCleanup(de_ctx); - if (de_ctx != NULL) - SigCleanSignatures(de_ctx); if (de_ctx != NULL) DetectEngineCtxFree(de_ctx);