From: Eric Leblond Date: Tue, 26 May 2015 09:31:41 +0000 (+0200) Subject: redis-output: fix sensor-name code X-Git-Tag: suricata-3.0RC1~48 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f11b269ef134d1822caa0eb9249fcf9b1a0a66b9;p=thirdparty%2Fsuricata.git redis-output: fix sensor-name code The sensor-name was not freed at exist and the result of SCStrdup was not checked. --- 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