]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
http2: avoid null pointer deref in alert output
authorVictor Julien <victor@inliniac.net>
Sat, 7 Nov 2020 14:34:35 +0000 (15:34 +0100)
committerVictor Julien <victor@inliniac.net>
Thu, 3 Dec 2020 12:01:11 +0000 (13:01 +0100)
Bug #4120.

src/output-json-alert.c

index 426a44114058ff8883f4f4ecbf248d03fc1bbe95..dc2714669f142191fa6d97bf5774d5533d6aa42b 100644 (file)
@@ -167,13 +167,15 @@ static void AlertJsonHttp2(const Flow *f, const uint64_t tx_id, JsonBuilder *js)
     void *h2_state = FlowGetAppState(f);
     if (h2_state) {
         void *tx_ptr = rs_http2_state_get_tx(h2_state, tx_id);
-        JsonBuilderMark mark = { 0, 0, 0 };
-        jb_get_mark(js, &mark);
-        jb_open_object(js, "http");
-        if (rs_http2_log_json(tx_ptr, js)) {
-            jb_close(js);
-        } else {
-            jb_restore_mark(js, &mark);
+        if (tx_ptr) {
+            JsonBuilderMark mark = { 0, 0, 0 };
+            jb_get_mark(js, &mark);
+            jb_open_object(js, "http");
+            if (rs_http2_log_json(tx_ptr, js)) {
+                jb_close(js);
+            } else {
+                jb_restore_mark(js, &mark);
+            }
         }
     }