]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
applayer: make sure to use correct ipproto
authorVictor Julien <vjulien@oisf.net>
Mon, 24 Oct 2022 18:20:30 +0000 (20:20 +0200)
committerVictor Julien <vjulien@oisf.net>
Tue, 25 Oct 2022 08:39:10 +0000 (10:39 +0200)
src/detect-filestore.c
src/output-lua.c
src/output-tx.c

index 70aa84679b04e5504ee5a99e2e66b5f197846342..4f0593327366055572409f2e8d32870568d38d2a 100644 (file)
@@ -154,10 +154,10 @@ static int FilestorePostMatchWithOptions(Packet *p, Flow *f, const DetectFilesto
     } else if (this_tx) {
         /* set in AppLayerTxData. Parsers and logger will propegate it to the
          * individual files, both new and current. */
-        void *txv = AppLayerParserGetTx(p->proto, f->alproto, f->alstate, tx_id);
+        void *txv = AppLayerParserGetTx(f->proto, f->alproto, f->alstate, tx_id);
         DEBUG_VALIDATE_BUG_ON(txv == NULL);
         if (txv != NULL) {
-            AppLayerTxData *txd = AppLayerParserGetTxData(p->proto, f->alproto, txv);
+            AppLayerTxData *txd = AppLayerParserGetTxData(f->proto, f->alproto, txv);
             DEBUG_VALIDATE_BUG_ON(txd == NULL);
             if (txd != NULL) {
                 txd->file_flags |= FLOWFILE_STORE;
@@ -167,7 +167,7 @@ static int FilestorePostMatchWithOptions(Packet *p, Flow *f, const DetectFilesto
         /* set in flow and AppLayerStateData */
         f->file_flags |= FLOWFILE_STORE;
 
-        AppLayerStateData *sd = AppLayerParserGetStateData(p->proto, f->alproto, f->alstate);
+        AppLayerStateData *sd = AppLayerParserGetStateData(f->proto, f->alproto, f->alstate);
         if (sd != NULL) {
             sd->file_flags |= FLOWFILE_STORE;
         }
@@ -206,7 +206,7 @@ static int DetectFilestorePostMatch(DetectEngineThreadCtx *det_ctx,
 #endif
     }
 
-    if (p->proto == IPPROTO_TCP && p->flow->protoctx != NULL) {
+    if (p->flow->proto == IPPROTO_TCP && p->flow->protoctx != NULL) {
         /* set filestore depth for stream reassembling */
         TcpSession *ssn = (TcpSession *)p->flow->protoctx;
         TcpSessionSetReassemblyDepth(ssn, FileReassemblyDepth());
index c6b09e53a09eff1f8fcea3eb137f64e113f75cf2..67a0dcb951d98659b93d2eb13c5b78a0a67b2071 100644 (file)
@@ -193,7 +193,8 @@ static int LuaPacketLoggerAlerts(ThreadVars *tv, void *thread_data, const Packet
 
         void *txptr = NULL;
         if (p->flow && p->flow->alstate && (pa->flags & PACKET_ALERT_FLAG_TX))
-            txptr = AppLayerParserGetTx(p->proto, p->flow->alproto, p->flow->alstate, pa->tx_id);
+            txptr = AppLayerParserGetTx(
+                    p->flow->proto, p->flow->alproto, p->flow->alstate, pa->tx_id);
 
         LuaStateSetThreadVars(td->lua_ctx->luastate, tv);
         LuaStateSetPacket(td->lua_ctx->luastate, (Packet *)p);
index 708c449a7c19fc98cceededbda08b1c786120efa..e51afc6d35ca804abb8942e5e5d55a841b6476be 100644 (file)
@@ -356,7 +356,7 @@ static TmEcode OutputTxLog(ThreadVars *tv, Packet *p, void *thread_data)
             /* No child loggers registered. */
             return TM_ECODE_OK;
         }
-        if (AppLayerParserProtocolHasLogger(p->proto, alproto) == 0)
+        if (AppLayerParserProtocolHasLogger(ipproto, alproto) == 0)
             goto end;
     }
     void *alstate = f->alstate;
@@ -364,7 +364,7 @@ static TmEcode OutputTxLog(ThreadVars *tv, Packet *p, void *thread_data)
         SCLogDebug("no alstate");
         goto end;
     }
-    const LoggerId logger_expectation = AppLayerParserProtocolGetLoggerBits(p->proto, alproto);
+    const LoggerId logger_expectation = AppLayerParserProtocolGetLoggerBits(ipproto, alproto);
     if (logger_expectation == 0) {
         SCLogDebug("bail: logger_expectation %u. LOGGER_FILE %u LOGGER_FILEDATA %u",
                 logger_expectation, LOGGER_FILE, LOGGER_FILEDATA);
@@ -389,7 +389,7 @@ static TmEcode OutputTxLog(ThreadVars *tv, Packet *p, void *thread_data)
     uint64_t max_id = tx_id;
     int logged = 0;
     int gap = 0;
-    const bool support_files = AppLayerParserSupportsFiles(p->proto, alproto);
+    const bool support_files = AppLayerParserSupportsFiles(ipproto, alproto);
     const uint8_t pkt_dir = STREAM_FLAGS_FOR_PACKET(p);
 
     SCLogDebug("pcap_cnt %" PRIu64 ": tx_id %" PRIu64 " total_txs %" PRIu64, p->pcap_cnt, tx_id,
@@ -412,9 +412,9 @@ static TmEcode OutputTxLog(ThreadVars *tv, Packet *p, void *thread_data)
         SCLogDebug("STARTING tx_id %" PRIu64 ", tx %p", tx_id, tx);
 
         const int tx_progress_ts =
-                AppLayerParserGetStateProgress(p->proto, alproto, tx, ts_disrupt_flags);
+                AppLayerParserGetStateProgress(ipproto, alproto, tx, ts_disrupt_flags);
         const int tx_progress_tc =
-                AppLayerParserGetStateProgress(p->proto, alproto, tx, tc_disrupt_flags);
+                AppLayerParserGetStateProgress(ipproto, alproto, tx, tc_disrupt_flags);
         const bool tx_complete = (tx_progress_ts == complete_ts && tx_progress_tc == complete_tc);
 
         SCLogDebug("file_thread_data %p filedata_thread_data %p", op_thread_data->file,