From: Philippe Antoine Date: Fri, 2 Dec 2022 12:55:42 +0000 (+0100) Subject: dns: do not oputput empty array for query X-Git-Tag: suricata-7.0.0-rc1~319 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=04fd2ae78e005197578c57153295404846cfcf0d;p=thirdparty%2Fsuricata.git dns: do not oputput empty array for query --- diff --git a/src/output-json-dns.c b/src/output-json-dns.c index 91825d24c0..2d1e7d3c4a 100644 --- a/src/output-json-dns.c +++ b/src/output-json-dns.c @@ -269,6 +269,7 @@ JsonBuilder *JsonDNSLogQuery(void *txptr, uint64_t tx_id) if (queryjb == NULL) { return NULL; } + bool has_query = false; for (uint16_t i = 0; i < UINT16_MAX; i++) { JsonBuilder *js = jb_new_object(); @@ -277,10 +278,16 @@ JsonBuilder *JsonDNSLogQuery(void *txptr, uint64_t tx_id) break; } jb_close(js); + has_query = true; jb_append_object(queryjb, js); jb_free(js); } + if (!has_query) { + jb_free(queryjb); + return NULL; + } + jb_close(queryjb); return queryjb; }