]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
output/json: Eliminate dangling XFF reference 6727/head
authorJeff Lucovsky <jeff@lucovsky.org>
Sun, 19 Dec 2021 18:08:59 +0000 (13:08 -0500)
committerVictor Julien <vjulien@oisf.net>
Sun, 19 Dec 2021 18:15:34 +0000 (19:15 +0100)
This commit eliminates a dangling reference caused by the use of
json_object_set. This function adds a reference to the final parameter
-- in this case the object returned by json_string() whereas
json_object_set_new doesn't add the additional reference to the
final parameter.

src/output-json-alert.c
src/output-json-file.c
src/output-json-http.c

index 175bf4f4cdf50d291fc6241156c30b0b47b1aed6..54398374b2541c2ff2b9c797e483f14a9a087b7b 100644 (file)
@@ -585,9 +585,9 @@ static int AlertJson(ThreadVars *tv, JsonAlertLogThread *aft, const Packet *p)
                 }
                 else if (xff_cfg->flags & XFF_OVERWRITE) {
                     if (p->flowflags & FLOW_PKT_TOCLIENT) {
-                        json_object_set(js, "dest_ip", json_string(buffer));
+                        json_object_set_new(js, "dest_ip", json_string(buffer));
                     } else {
-                        json_object_set(js, "src_ip", json_string(buffer));
+                        json_object_set_new(js, "src_ip", json_string(buffer));
                     }
                 }
             }
index 17134a477a6d84bf514108470993748b022c9f25..3ff42454cb00475536e4d04fa4c48df05fad65aa 100644 (file)
@@ -234,9 +234,9 @@ json_t *JsonBuildFileInfoRecord(const Packet *p, const File *ff,
             }
             else if (xff_cfg->flags & XFF_OVERWRITE) {
                 if (p->flowflags & FLOW_PKT_TOCLIENT) {
-                    json_object_set(js, "dest_ip", json_string(buffer));
+                    json_object_set_new(js, "dest_ip", json_string(buffer));
                 } else {
-                    json_object_set(js, "src_ip", json_string(buffer));
+                    json_object_set_new(js, "src_ip", json_string(buffer));
                 }
             }
         }
index 2e3a62ecf2c3175f8f6c487bf12a69aa37918a28..a95cbbe46da4fd8caad922b68224ada18a22f807 100644 (file)
@@ -545,9 +545,9 @@ static int JsonHttpLogger(ThreadVars *tv, void *thread_data, const Packet *p, Fl
             }
             else if (xff_cfg->flags & XFF_OVERWRITE) {
                 if (p->flowflags & FLOW_PKT_TOCLIENT) {
-                    json_object_set(js, "dest_ip", json_string(buffer));
+                    json_object_set_new(js, "dest_ip", json_string(buffer));
                 } else {
-                    json_object_set(js, "src_ip", json_string(buffer));
+                    json_object_set_new(js, "src_ip", json_string(buffer));
                 }
             }
         }