Prepare for 0.9.8ze-dev
[oweals/openssl.git] / crypto / asn1 / asn1_lib.c
index 504e612a853b4231d68d8f13d8a30f2667a59bd2..d34515577e6eb8226d1d25748a28f9f112e1ffba 100644 (file)
@@ -64,7 +64,7 @@
 
 static int asn1_get_length(const unsigned char **pp,int *inf,long *rl,int max);
 static void asn1_put_length(unsigned char **pp, int length);
-const char *ASN1_version="ASN.1" OPENSSL_VERSION_PTEXT;
+const char ASN1_version[]="ASN.1" OPENSSL_VERSION_PTEXT;
 
 static int _asn1_check_infinite_end(const unsigned char **p, long len)
        {
@@ -131,6 +131,9 @@ int ASN1_get_object(const unsigned char **pp, long *plength, int *ptag,
        *pclass=xclass;
        if (!asn1_get_length(&p,&inf,plength,(int)max)) goto err;
 
+       if (inf && !(ret & V_ASN1_CONSTRUCTED))
+               goto err;
+
 #if 0
        fprintf(stderr,"p=%d + *plength=%ld > omax=%ld + *pp=%d  (%d > %d)\n", 
                (int)p,*plength,omax,(int)*pp,(int)(p+ *plength),
@@ -378,6 +381,7 @@ int ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len)
 
                if (str->data == NULL)
                        {
+                       ASN1err(ASN1_F_ASN1_STRING_SET,ERR_R_MALLOC_FAILURE);
                        str->data=c;
                        return(0);
                        }
@@ -392,6 +396,14 @@ int ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len)
        return(1);
        }
 
+void ASN1_STRING_set0(ASN1_STRING *str, void *data, int len)
+       {
+       if (str->data)
+               OPENSSL_free(str->data);
+       str->data = data;
+       str->length = len;
+       }
+
 ASN1_STRING *ASN1_STRING_new(void)
        {
        return(ASN1_STRING_type_new(V_ASN1_OCTET_STRING));