]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
TLS parser: modify OCTETSTRING
authorEric Leblond <eric@regit.org>
Fri, 25 Nov 2011 17:40:34 +0000 (18:40 +0100)
committerVictor Julien <victor@inliniac.net>
Mon, 19 Mar 2012 11:12:25 +0000 (12:12 +0100)
This patch does on over allocation of 1 for the OCTETSTRING
to be able to add a 0 at the end. This will then
allow us to use the string in printf.

src/util-decode-der.c

index 8f7974b267972c8796dabeb62562a9788ab2d086..2f530b84a7291667e71f308aacae79ee5ce92b6d 100644 (file)
@@ -505,12 +505,15 @@ static Asn1Generic * DecodeAsn1DerOctetString(const unsigned char *buffer, uint3
         return NULL;
     a->type = ASN1_OCTETSTRING;
     a->strlen = length;
-    a->str = SCMalloc(length);
+    /* Add one to the octet string for the 0. This will then
+     * allow us to use the string in printf */
+    a->str = SCMalloc(length + 1);
     if (a->str == NULL) {
         SCFree(a);
         return NULL;
     }
     memcpy(a->str, (const char*)d_ptr, length);
+    a->str[length] = 0;
 
     d_ptr += length;