From f11b269ef134d1822caa0eb9249fcf9b1a0a66b9 Mon Sep 17 00:00:00 2001 From: Eric Leblond Date: Tue, 26 May 2015 11:31:41 +0200 Subject: [PATCH] redis-output: fix sensor-name code The sensor-name was not freed at exist and the result of SCStrdup was not checked. --- src/output-json.c | 6 ++++++ src/util-logopenfile.c | 1 + 2 files changed, 7 insertions(+) diff --git a/src/output-json.c b/src/output-json.c index 99032a5481..a4364d2d9d 100644 --- a/src/output-json.c +++ b/src/output-json.c @@ -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); diff --git a/src/util-logopenfile.c b/src/util-logopenfile.c index c8b335b263..89f59d8dac 100644 --- a/src/util-logopenfile.c +++ b/src/util-logopenfile.c @@ -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 -- 2.47.2