From afb48cfcb58829e6f2df527520d2c77c73e9616c Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Mon, 9 Dec 2013 16:42:33 +0100 Subject: [PATCH] log-http: fix error check leading to null-deref on malloc failure during setup --- src/log-httplog.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/log-httplog.c b/src/log-httplog.c index 178b511e08..ef87d9f57b 100644 --- a/src/log-httplog.c +++ b/src/log-httplog.c @@ -704,7 +704,6 @@ OutputCtx *LogHttpLogInitCtx(ConfNode *conf) for (httplog_ctx->cf_n = 0; httplog_ctx->cf_n < LOG_HTTP_MAXN_NODES-1 && p && *p != '\0'; httplog_ctx->cf_n++){ httplog_ctx->cf_nodes[httplog_ctx->cf_n] = SCMalloc(sizeof(LogHttpCustomFormatNode)); - httplog_ctx->cf_nodes[httplog_ctx->cf_n]->maxlen=0; if (httplog_ctx->cf_nodes[httplog_ctx->cf_n] == NULL) { for (n = 0; n < httplog_ctx->cf_n; n++) { SCFree(httplog_ctx->cf_nodes[n]); @@ -713,6 +712,8 @@ OutputCtx *LogHttpLogInitCtx(ConfNode *conf) SCFree(httplog_ctx); return NULL; } + httplog_ctx->cf_nodes[httplog_ctx->cf_n]->maxlen = 0; + if (*p != '%'){ /* Literal found in format string */ httplog_ctx->cf_nodes[httplog_ctx->cf_n]->type = LOG_HTTP_CF_LITERAL;