From: Victor Julien Date: Mon, 23 Nov 2015 08:56:51 +0000 (+0100) Subject: json: fix malformed output X-Git-Tag: suricata-3.0RC1~22 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bec913b40cf9153fd6a021b33cecda97ff76be47;p=thirdparty%2Fsuricata.git json: fix malformed output 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. --- diff --git a/src/output-json.c b/src/output-json.c index 9cc9bd94b4..fcc3a9559e 100644 --- a/src/output-json.c +++ b/src/output-json.c @@ -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; }