From: Victor Julien Date: Tue, 24 Sep 2019 09:30:38 +0000 (+0200) Subject: detect/port: remove function only used in tests X-Git-Tag: suricata-5.0.0~132 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8b0b301a151a11de6a463e0ec4905467d0b64d23;p=thirdparty%2Fsuricata.git detect/port: remove function only used in tests --- diff --git a/src/detect-engine-port.c b/src/detect-engine-port.c index f385b974ef..f3cbb196d9 100644 --- a/src/detect-engine-port.c +++ b/src/detect-engine-port.c @@ -623,42 +623,6 @@ int DetectPortCmp(DetectPort *a, DetectPort *b) return PORT_ER; } -/** - * \brief Function that return a copy of DetectPort src - * - * \param de_ctx Pointer to the current Detection Engine Context - * \param src Pointer to a DetectPort group to copy - * - * \retval Pointer to a DetectPort instance (copy of src) - * \retval NULL on error - * - * \todo rewrite to avoid recursive calls - * */ -DetectPort *DetectPortCopy(DetectEngineCtx *de_ctx, DetectPort *src) -{ - if (src == NULL) - return NULL; - - DetectPort *dst = DetectPortInit(); - if (dst == NULL) { - goto error; - } - - dst->port = src->port; - dst->port2 = src->port2; - - if (src->next != NULL) { - dst->next = DetectPortCopy(de_ctx, src->next); - if (dst->next != NULL) { - dst->next->prev = dst; - } - } - - return dst; -error: - return NULL; -} - /** * \brief Function that return a copy of DetectPort src sigs * @@ -1727,40 +1691,6 @@ static int PortTestParse05 (void) PASS; } -/** - * \test Check if we copy a DetectPort correctly - */ -static int PortTestParse06 (void) -{ - DetectPort *dd = NULL, *copy = NULL; - - int r = DetectPortParse(NULL,&dd,"22"); - FAIL_IF_NOT(r == 0); - r = DetectPortParse(NULL,&dd,"80"); - FAIL_IF_NOT(r == 0); - r = DetectPortParse(NULL,&dd,"143"); - FAIL_IF_NOT(r == 0); - - copy = DetectPortCopy(NULL,dd); - FAIL_IF_NULL(copy); - - FAIL_IF(DetectPortCmp(dd,copy) != PORT_EQ); - FAIL_IF_NULL(copy->next); - - FAIL_IF(DetectPortCmp(dd->next,copy->next) != PORT_EQ); - FAIL_IF_NULL(copy->next->next); - - FAIL_IF(DetectPortCmp(dd->next->next,copy->next->next) != PORT_EQ); - - FAIL_IF_NOT(copy->port == 22); - FAIL_IF_NOT(copy->next->port == 80); - FAIL_IF_NOT(copy->next->next->port == 143); - - DetectPortCleanupList(NULL, copy); - DetectPortCleanupList(NULL, dd); - PASS; -} - /** * \test Check if a negated port range is properly fragmented in the allowed * real groups @@ -1902,44 +1832,6 @@ static int PortTestParse15 (void) PASS; } -/** - * \test Test parse, copy and cmp functions - */ -static int PortTestParse16 (void) -{ - DetectPort *dd = NULL, *copy = NULL; - - int r = DetectPortParse(NULL,&dd,"22"); - FAIL_IF_NOT(r == 0); - r = DetectPortParse(NULL,&dd,"80"); - FAIL_IF_NOT(r == 0); - r = DetectPortParse(NULL,&dd,"143"); - FAIL_IF_NOT(r == 0); - - copy = DetectPortCopy(NULL,dd); - FAIL_IF_NULL(copy); - - FAIL_IF(DetectPortCmp(dd,copy) != PORT_EQ); - - FAIL_IF_NULL(copy->next); - - FAIL_IF(DetectPortCmp(dd->next,copy->next) != PORT_EQ); - - FAIL_IF_NULL(copy->next->next); - - FAIL_IF(DetectPortCmp(dd->next->next,copy->next->next) != PORT_EQ); - - FAIL_IF_NOT(copy->port == 22); - FAIL_IF_NOT(copy->next->port == 80); - FAIL_IF_NOT(copy->next->next->port == 143); - - FAIL_IF(copy->next->prev != copy); - - DetectPortCleanupList(NULL, copy); - DetectPortCleanupList(NULL, dd); - PASS; -} - /** * \test Test general functions */ @@ -2646,7 +2538,6 @@ void DetectPortTests(void) UtRegisterTest("PortTestParse03", PortTestParse03); UtRegisterTest("PortTestParse04", PortTestParse04); UtRegisterTest("PortTestParse05", PortTestParse05); - UtRegisterTest("PortTestParse06", PortTestParse06); UtRegisterTest("PortTestParse07", PortTestParse07); UtRegisterTest("PortTestParse08", PortTestParse08); UtRegisterTest("PortTestParse09", PortTestParse09); @@ -2656,7 +2547,6 @@ void DetectPortTests(void) UtRegisterTest("PortTestParse13", PortTestParse13); UtRegisterTest("PortTestParse14", PortTestParse14); UtRegisterTest("PortTestParse15", PortTestParse15); - UtRegisterTest("PortTestParse16", PortTestParse16); UtRegisterTest("PortTestFunctions01", PortTestFunctions01); UtRegisterTest("PortTestFunctions02", PortTestFunctions02); UtRegisterTest("PortTestFunctions03", PortTestFunctions03); diff --git a/src/detect-engine-port.h b/src/detect-engine-port.h index b692c3e5bc..0a59dee07d 100644 --- a/src/detect-engine-port.h +++ b/src/detect-engine-port.h @@ -27,7 +27,6 @@ /* prototypes */ int DetectPortParse(const DetectEngineCtx *, DetectPort **head, const char *str); -DetectPort *DetectPortCopy(DetectEngineCtx *, DetectPort *); DetectPort *DetectPortCopySingle(DetectEngineCtx *, DetectPort *); int DetectPortInsertCopy(DetectEngineCtx *,DetectPort **, DetectPort *); int DetectPortInsert(DetectEngineCtx *,DetectPort **, DetectPort *);