]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
conf: fix potential use-after-free on error 730/head
authorVictor Julien <victor@inliniac.net>
Wed, 18 Dec 2013 11:23:50 +0000 (12:23 +0100)
committerVictor Julien <victor@inliniac.net>
Wed, 18 Dec 2013 11:23:50 +0000 (12:23 +0100)
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.

src/conf.c

index 104f92ad06f395c14ca9bb7f7d6f4f373858d2e6..cabde9e36fb99f7c65b445c8d3c377f9cb6b8c5f 100644 (file)
@@ -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;