]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
app-layer: remove obsolete NULL check 13079/head
authorPhilippe Antoine <pantoine@oisf.net>
Tue, 22 Apr 2025 19:15:53 +0000 (21:15 +0200)
committerVictor Julien <victor@inliniac.net>
Tue, 22 Apr 2025 20:43:06 +0000 (22:43 +0200)
Completes commit 833a738dd1429f63c79d95edf25bb86fcc15b51a

Fixes coverity 1646610

src/app-layer-parser.c
src/detect-engine-state.c
src/detect-xbits.c
src/detect.c

index 9139b73db8f8ca50c3b73c1902f7258220f2a0ca..e6693e9c8add5fd458d7c9253dd83ad35dccc3e1 100644 (file)
@@ -953,13 +953,11 @@ void AppLayerParserTransactionsCleanup(Flow *f, const uint8_t pkt_dir)
                         (pkt_dir == STREAM_TOSERVER) ? ts_disrupt_flags : tc_disrupt_flags);
             AppLayerParserFileTxHousekeeping(f, tx, pkt_dir, (bool)pkt_dir_trunc);
         }
-        if (txd) {
-            // should be reset by parser next time it updates the tx
-            if (pkt_dir & STREAM_TOSERVER) {
-                txd->updated_ts = false;
-            } else {
-                txd->updated_tc = false;
-            }
+        // should be reset by parser next time it updates the tx
+        if (pkt_dir & STREAM_TOSERVER) {
+            txd->updated_ts = false;
+        } else {
+            txd->updated_tc = false;
         }
         const int tx_progress_tc =
                 AppLayerParserGetStateProgress(ipproto, alproto, tx, tc_disrupt_flags);
@@ -976,7 +974,7 @@ void AppLayerParserTransactionsCleanup(Flow *f, const uint8_t pkt_dir)
             goto next;
         }
 
-        if (txd && has_tx_detect_flags) {
+        if (has_tx_detect_flags) {
             if (!IS_DISRUPTED(ts_disrupt_flags) &&
                     (f->sgh_toserver != NULL || (f->flags & FLOW_SGH_TOSERVER) == 0)) {
                 if ((txd->flags & (APP_LAYER_TX_INSPECTED_TS | APP_LAYER_TX_SKIP_INSPECT_TS)) ==
@@ -1003,7 +1001,7 @@ void AppLayerParserTransactionsCleanup(Flow *f, const uint8_t pkt_dir)
             goto next;
         }
 
-        if (txd && logger_expectation != 0) {
+        if (logger_expectation != 0) {
             LoggerId tx_logged = GetTxLogged(txd);
             if (tx_logged != logger_expectation) {
                 SCLogDebug("%p/%"PRIu64" skipping: logging not done: want:%"PRIx32", have:%"PRIx32,
@@ -1015,19 +1013,17 @@ void AppLayerParserTransactionsCleanup(Flow *f, const uint8_t pkt_dir)
 
         /* if file logging is enabled, we keep a tx active while some of the files aren't
          * logged yet. */
-        if (txd) {
-            SCLogDebug("files_opened %u files_logged %u files_stored %u", txd->files_opened,
-                    txd->files_logged, txd->files_stored);
-
-            if (txd->files_opened) {
-                if (g_file_logger_enabled && txd->files_opened != txd->files_logged) {
-                    skipped = true;
-                    goto next;
-                }
-                if (g_filedata_logger_enabled && txd->files_opened != txd->files_stored) {
-                    skipped = true;
-                    goto next;
-                }
+        SCLogDebug("files_opened %u files_logged %u files_stored %u", txd->files_opened,
+                txd->files_logged, txd->files_stored);
+
+        if (txd->files_opened) {
+            if (g_file_logger_enabled && txd->files_opened != txd->files_logged) {
+                skipped = true;
+                goto next;
+            }
+            if (g_filedata_logger_enabled && txd->files_opened != txd->files_stored) {
+                skipped = true;
+                goto next;
             }
         }
 
index f887cbfb36e54a44f5ec66a760408bcf1cfecea6..1010f1805b623a413c9a3e25f88fb34343cef516 100644 (file)
@@ -275,10 +275,7 @@ void DetectEngineStateResetTxs(Flow *f)
         void *inspect_tx = AppLayerParserGetTx(f->proto, f->alproto, alstate, inspect_tx_id);
         if (inspect_tx != NULL) {
             AppLayerTxData *txd = AppLayerParserGetTxData(f->proto, f->alproto, inspect_tx);
-            BUG_ON(txd == NULL);
-            if (txd) {
-                ResetTxState(txd->de_state);
-            }
+            ResetTxState(txd->de_state);
         }
     }
 }
index ca24ca4738c2bb95ef25f2ba191e3d7e9383baa0..b4e39c292e1c067ec5949f9670902ca683a0d80f 100644 (file)
@@ -175,9 +175,6 @@ static int DetectXbitPostMatchTx(
     if (txv == NULL)
         return 0;
     AppLayerTxData *txd = AppLayerParserGetTxData(f->proto, f->alproto, txv);
-    if (txd == NULL) {
-        return 0;
-    }
 
     if (xd->cmd != DETECT_XBITS_CMD_SET)
         return 0;
index d0da67757816d7a254b1a8bb33a4eeb19d1871a3..6b771fe61e394793f1ad0d32035a26bd69ac6973 100644 (file)
@@ -1404,12 +1404,10 @@ static inline void StoreDetectProgress(
         DetectTransaction *tx, const uint8_t flow_flags, const uint8_t progress)
 {
     AppLayerTxData *txd = (AppLayerTxData *)tx->tx_data_ptr;
-    if (likely(txd != NULL)) {
-        if (flow_flags & STREAM_TOSERVER) {
-            txd->detect_progress_ts = progress;
-        } else {
-            txd->detect_progress_tc = progress;
-        }
+    if (flow_flags & STREAM_TOSERVER) {
+        txd->detect_progress_ts = progress;
+    } else {
+        txd->detect_progress_tc = progress;
     }
 }