]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
output/fileinfo: Optimize filename output
authorJeff Lucovsky <jeff@lucovsky.org>
Mon, 29 Jun 2020 13:54:15 +0000 (09:54 -0400)
committerVictor Julien <victor@inliniac.net>
Mon, 29 Jun 2020 18:02:40 +0000 (20:02 +0200)
This commit optimizes the JSON preparation of the file name by
eliminating the temporary copy before adding to the Json builder buffer.

src/output-json.c

index c159d3509d232c11e505b6c43e3f870f19351e67..3d3eeb173b2820984ce202174eaa37c4ea15dafa 100644 (file)
@@ -137,10 +137,7 @@ static int64_t sensor_id = -1; /* -1 = not defined */
 
 void EveFileInfo(JsonBuilder *jb, const File *ff, const bool stored)
 {
-    size_t filename_size = ff->name_len * 2 + 1;
-    char filename_string[filename_size];
-    BytesToStringBuffer(ff->name, ff->name_len, filename_string, filename_size);
-    jb_set_string(jb, "filename", filename_string);
+    jb_set_string_from_bytes(jb, "filename", ff->name, ff->name_len);
 
     jb_open_array(jb, "sid");
     for (uint32_t i = 0; ff->sid != NULL && i < ff->sid_cnt; i++) {