]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
json: fix malformed output 1754/head
authorVictor Julien <victor@inliniac.net>
Mon, 23 Nov 2015 08:56:51 +0000 (09:56 +0100)
committerVictor Julien <victor@inliniac.net>
Mon, 23 Nov 2015 08:56:51 +0000 (09:56 +0100)
Even though the json output callback is called with a null terminated
string, it's not useable directly. The size parameter to the callback
might be a lot smaller than the string size. Libjansson gives the size
up to the first point that needs escaping.

src/output-json.c

index 9cc9bd94b4e0d9e06ef1a0c8a9e15cfd805d7b3b..fcc3a9559e706cf5bccd4f4545d8771efa04b23e 100644 (file)
@@ -345,7 +345,7 @@ static int MemBufferCallback(const char *str, size_t size, void *data)
         MemBufferExpand(&memb, OUTPUT_BUFFER_SIZE);
     }
 #endif
-    MemBufferWriteString(memb, "%s", str);
+    MemBufferWriteRaw(memb, str, size);
     return 0;
 }