]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect/mpm: don't test for impossible condition
authorVictor Julien <vjulien@oisf.net>
Fri, 5 Jan 2024 07:29:16 +0000 (08:29 +0100)
committerVictor Julien <victor@inliniac.net>
Thu, 29 Feb 2024 10:24:41 +0000 (11:24 +0100)
Functions can't get called with NULL signature or NULL
Signature::init_data.

(cherry picked from commit 124a8dea204b400f27ac2b8c15c994ffa996b1ea)

src/detect-engine-mpm.c

index f091a3dadaa0acc4a903e3e2c5c85affa7826ed6..ede3e594d927644f32fc42fe5c2b8614f1889107 100644 (file)
@@ -772,18 +772,12 @@ int SignatureHasPacketContent(const Signature *s)
 {
     SCEnter();
 
-    if (s == NULL) {
-        SCReturnInt(0);
-    }
-
     if (!(s->proto.proto[IPPROTO_TCP / 8] & 1 << (IPPROTO_TCP % 8))) {
         SCReturnInt(1);
     }
 
-    if ((s->init_data != NULL && s->init_data->smlists[DETECT_SM_LIST_PMATCH] == NULL) ||
-        (s->init_data == NULL && s->sm_arrays[DETECT_SM_LIST_PMATCH] == NULL))
-    {
-        SCLogDebug("no mpm");
+    if (s->init_data->smlists[DETECT_SM_LIST_PMATCH] == NULL) {
+        SCLogDebug("no PMATCH");
         SCReturnInt(0);
     }
 
@@ -808,18 +802,12 @@ int SignatureHasStreamContent(const Signature *s)
 {
     SCEnter();
 
-    if (s == NULL) {
-        SCReturnInt(0);
-    }
-
     if (!(s->proto.proto[IPPROTO_TCP / 8] & 1 << (IPPROTO_TCP % 8))) {
         SCReturnInt(0);
     }
 
-    if ((s->init_data != NULL && s->init_data->smlists[DETECT_SM_LIST_PMATCH] == NULL) ||
-        (s->init_data == NULL && s->sm_arrays[DETECT_SM_LIST_PMATCH] == NULL))
-    {
-        SCLogDebug("no mpm");
+    if (s->init_data->smlists[DETECT_SM_LIST_PMATCH] == NULL) {
+        SCLogDebug("no PMATCH");
         SCReturnInt(0);
     }