Double-check that a blob passed to is_asn1() is not empty

This commit is contained in:
Martin Willi
2010-05-05 11:35:53 +02:00
parent c60b69e4bf
commit 37c2aac89d
+7 -1
View File
@@ -497,8 +497,14 @@ int asn1_parse_algorithmIdentifier(chunk_t blob, int level0, chunk_t *parameters
bool is_asn1(chunk_t blob) bool is_asn1(chunk_t blob)
{ {
u_int len; u_int len;
u_char tag = *blob.ptr; u_char tag;
if (!blob.len || !blob.ptr)
{
return FALSE;
}
tag = *blob.ptr;
if (tag != ASN1_SEQUENCE && tag != ASN1_SET && tag != ASN1_OCTET_STRING) if (tag != ASN1_SEQUENCE && tag != ASN1_SET && tag != ASN1_OCTET_STRING)
{ {
DBG2(DBG_LIB, " file content is not binary ASN.1"); DBG2(DBG_LIB, " file content is not binary ASN.1");