Skip to content

Commit

Permalink
http-json: init 'fields' to 0 before setting it
Browse files Browse the repository at this point in the history
httplog_ctx->fields would not be initialized before setting flags in
it:

Scanbuild:
output-json-http.c:491:46: warning: The left expression of the compound assignment is an uninitialized value. The computed value will also be garbage
                            http_ctx->fields |= (1<<f);
                            ~~~~~~~~~~~~~~~~ ^
1 warning generated.

Drmemory:
~~27874~~ Error #1: UNINITIALIZED READ: reading register eax
~~27874~~ # 0 JsonHttpLogJSON                       [/home/buildbot/qa/buildbot/donkey/drmemory/Suricata/src/output-json-http.c:260]
~~27874~~ # 1 JsonHttpLogger                        [/home/buildbot/qa/buildbot/donkey/drmemory/Suricata/src/output-json-http.c:375]

Just memset the whole structure right after initialition.
  • Loading branch information
victorjulien committed May 2, 2014
1 parent 7df9b28 commit 2002067
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/output-json-http.c
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,7 @@ OutputCtx *OutputHttpLogInitSub(ConfNode *conf, OutputCtx *parent_ctx)
LogHttpFileCtx *http_ctx = SCMalloc(sizeof(LogHttpFileCtx));
if (unlikely(http_ctx == NULL))
return NULL;
memset(http_ctx, 0x00, sizeof(*http_ctx));

OutputCtx *output_ctx = SCCalloc(1, sizeof(OutputCtx));
if (unlikely(output_ctx == NULL)) {
Expand Down

0 comments on commit 2002067

Please sign in to comment.