]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
output-json-dns: allocate correct size hexstring buffer
authorJason Ish <ish@unx.ca>
Tue, 23 Aug 2016 16:00:54 +0000 (10:00 -0600)
committerJason Ish <ish@unx.ca>
Tue, 23 Aug 2016 17:15:19 +0000 (11:15 -0600)
The buffer allocated for the hexstring was not large enough
for a ':' separated hex string.

src/output-json-dns.c

index 11173ccc0e545bfc221c4b696529bd8a6bff5a8b..2eacb10d13aae711928f2d62ae7a70cb1d538a33 100644 (file)
@@ -181,7 +181,8 @@ static void OutputAnswer(LogDnsLogThread *aft, json_t *djs, DNSTransaction *tx,
                 /* turn fp raw buffer into a nice :-separate hex string */
                 uint16_t fp_len = (entry->data_len - 2);
                 uint8_t *dptr = ptr+2;
-                uint32_t output_len = fp_len * 2 + 1; // create c-string, so add space for 0.
+                /* c-string for ':' separated hex and trailing \0. */
+                uint32_t output_len = fp_len * 3 + 1;
                 char hexstring[output_len], *p = hexstring;
                 memset(hexstring, 0x00, output_len);