TLS parser: modify OCTETSTRING

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.
remotes/origin/HEAD
Eric Leblond 14 years ago committed by Victor Julien
parent 5a65a17f00
commit cb1a75fc9e

@ -505,12 +505,15 @@ static Asn1Generic * DecodeAsn1DerOctetString(const unsigned char *buffer, uint3
return NULL; return NULL;
a->type = ASN1_OCTETSTRING; a->type = ASN1_OCTETSTRING;
a->strlen = length; 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) { if (a->str == NULL) {
SCFree(a); SCFree(a);
return NULL; return NULL;
} }
memcpy(a->str, (const char*)d_ptr, length); memcpy(a->str, (const char*)d_ptr, length);
a->str[length] = 0;
d_ptr += length; d_ptr += length;

Loading…
Cancel
Save