]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
util-decode-der: fix hang detected by AFL 1997/head
authorMats Klepsland <mats.klepsland@gmail.com>
Sun, 10 Apr 2016 12:57:19 +0000 (14:57 +0200)
committerVictor Julien <victor@inliniac.net>
Mon, 11 Apr 2016 12:13:31 +0000 (14:13 +0200)
Fix hang that occurs when child->length is zero, resulting in an
endless loop.

src/util-decode-der.c

index f97497665f77aa86a427e8f1df4907d5e19a770d..be56b5e546f7589d3af864963536f2542a27fb47 100644 (file)
@@ -270,6 +270,12 @@ static Asn1Generic * DecodeAsn1DerGeneric(const unsigned char *buffer,
     if (child == NULL)
         return NULL;
 
+    /* child length should never be zero */
+    if (child->length == 0) {
+        SCFree(child);
+        return NULL;
+    }
+
     child->header = el;
     return child;
 }