From: Victor Julien Date: Wed, 18 Dec 2013 11:23:50 +0000 (+0100) Subject: conf: fix potential use-after-free on error X-Git-Tag: suricata-2.0beta2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F730%2Fhead;p=thirdparty%2Fsuricata.git conf: fix potential use-after-free on error Coverity 1139544 If strdup would fail, 'node' was freed but it wasn't set to NULL. The code then returned node. The caller would not detect there was an error and use the freed pointer. --- diff --git a/src/conf.c b/src/conf.c index 104f92ad06..cabde9e36f 100644 --- a/src/conf.c +++ b/src/conf.c @@ -91,6 +91,7 @@ ConfGetNodeOrCreate(char *name, int final) node->name = SCStrdup(key); if (unlikely(node->name == NULL)) { ConfNodeFree(node); + node = NULL; SCLogWarning(SC_ERR_MEM_ALLOC, "Failed to allocate memory for configuration."); goto end;