]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect/port: remove function only used in tests
authorVictor Julien <victor@inliniac.net>
Tue, 24 Sep 2019 09:30:38 +0000 (11:30 +0200)
committerVictor Julien <victor@inliniac.net>
Wed, 25 Sep 2019 08:45:27 +0000 (10:45 +0200)
src/detect-engine-port.c
src/detect-engine-port.h

index f385b974ef42ef3fb27f2e59c858b8ca397ce656..f3cbb196d930d62e2d90ed37b15836b6e748af45 100644 (file)
@@ -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);
index b692c3e5bc3fd0af812a60290b5aad633b76b167..0a59dee07d86307fc7a5fc3d67230ca672cab432 100644 (file)
@@ -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 *);