]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
redis-output: fix sensor-name code
authorEric Leblond <eric@regit.org>
Tue, 26 May 2015 09:31:41 +0000 (11:31 +0200)
committerVictor Julien <victor@inliniac.net>
Thu, 22 Oct 2015 08:01:05 +0000 (10:01 +0200)
The sensor-name was not freed at exist and the result of SCStrdup
was not checked.

src/output-json.c
src/util-logopenfile.c

index 99032a5481cb736179b3ca1ee71ac770026273cb..a4364d2d9d9c442b08017f46c62499830665f2b4 100644 (file)
@@ -546,6 +546,12 @@ OutputCtx *OutputJsonInitCtx(ConfNode *conf)
                 sensor_name = hostname;
             }
             json_ctx->file_ctx->redis_setup.sensor_name = SCStrdup(sensor_name);
+            if (json_ctx->file_ctx->redis_setup.sensor_name  == NULL) {
+                LogFileFreeCtx(json_ctx->file_ctx);
+                SCFree(json_ctx);
+                SCFree(output_ctx);
+                return NULL;
+            }
 
             if (SCConfLogOpenRedis(redis_node, json_ctx->file_ctx) < 0) {
                 LogFileFreeCtx(json_ctx->file_ctx);
index c8b335b263e8af31ebb356cc786cf729ddd7c4ec..89f59d8dac93d3b34bd11fb4d9fb8022d138b222 100644 (file)
@@ -500,6 +500,7 @@ int LogFileFreeCtx(LogFileCtx *lf_ctx)
         SCFree(lf_ctx->redis_setup.server);
         SCFree(lf_ctx->redis_setup.command);
         SCFree(lf_ctx->redis_setup.key);
+        SCFree(lf_ctx->redis_setup.sensor_name);
     }
 #endif