From: Victor Julien Date: Mon, 9 Dec 2013 15:42:33 +0000 (+0100) Subject: log-http: fix error check leading to null-deref on malloc failure during setup X-Git-Tag: suricata-2.0beta2~54 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F694%2Fhead;p=thirdparty%2Fsuricata.git log-http: fix error check leading to null-deref on malloc failure during setup --- 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;