From: Jeff Lucovsky Date: Sun, 19 Dec 2021 18:08:59 +0000 (-0500) Subject: output/json: Eliminate dangling XFF reference X-Git-Tag: suricata-5.0.9~115 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0fbffb3b74d6cbbc2062bb5a181279762d276ad6;p=thirdparty%2Fsuricata.git output/json: Eliminate dangling XFF reference 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. --- diff --git a/src/output-json-alert.c b/src/output-json-alert.c index 175bf4f4cd..54398374b2 100644 --- a/src/output-json-alert.c +++ b/src/output-json-alert.c @@ -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)); } } } diff --git a/src/output-json-file.c b/src/output-json-file.c index 17134a477a..3ff42454cb 100644 --- a/src/output-json-file.c +++ b/src/output-json-file.c @@ -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)); } } } diff --git a/src/output-json-http.c b/src/output-json-http.c index 2e3a62ecf2..a95cbbe46d 100644 --- a/src/output-json-http.c +++ b/src/output-json-http.c @@ -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)); } } }