Double-check that a blob passed to is_asn1() is not empty
authorMartin Willi <martin@revosec.ch>
Wed, 5 May 2010 09:26:17 +0000 (11:26 +0200)
committerMartin Willi <martin@revosec.ch>
Wed, 5 May 2010 09:35:53 +0000 (11:35 +0200)
src/libstrongswan/asn1/asn1.c

index 6264bdc..6f549d4 100644 (file)
@@ -497,8 +497,14 @@ int asn1_parse_algorithmIdentifier(chunk_t blob, int level0, chunk_t *parameters
 bool is_asn1(chunk_t blob)
 {
        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)
        {
                DBG2(DBG_LIB, "  file content is not binary ASN.1");