From: Philippe Antoine Date: Tue, 22 Apr 2025 19:15:53 +0000 (+0200) Subject: app-layer: remove obsolete NULL check X-Git-Tag: suricata-8.0.0-rc1~426 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f301cd370205af7e069680c286252304ab128214;p=thirdparty%2Fsuricata.git app-layer: remove obsolete NULL check Completes commit 833a738dd1429f63c79d95edf25bb86fcc15b51a Fixes coverity 1646610 --- diff --git a/src/app-layer-parser.c b/src/app-layer-parser.c index 9139b73db8..e6693e9c8a 100644 --- a/src/app-layer-parser.c +++ b/src/app-layer-parser.c @@ -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; } } diff --git a/src/detect-engine-state.c b/src/detect-engine-state.c index f887cbfb36..1010f1805b 100644 --- a/src/detect-engine-state.c +++ b/src/detect-engine-state.c @@ -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); } } } diff --git a/src/detect-xbits.c b/src/detect-xbits.c index ca24ca4738..b4e39c292e 100644 --- a/src/detect-xbits.c +++ b/src/detect-xbits.c @@ -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; diff --git a/src/detect.c b/src/detect.c index d0da677578..6b771fe61e 100644 --- a/src/detect.c +++ b/src/detect.c @@ -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; } }