PR: 2742
[openssl.git] / crypto / asn1 / asn1_par.c
index def7bcf2f1c76f5e026814a13288df75e36c312a..aaca69aebd94ca286bac91742f5db55957674109 100644 (file)
 #include <openssl/asn1.h>
 
 static int asn1_print_info(BIO *bp, int tag, int xclass,int constructed,
-                          int indent);
-static int asn1_parse2(BIO *bp, const unsigned char **pp, size_t length,
-                      int offset, int depth, int indent, int dump);
+       int indent);
+static int asn1_parse2(BIO *bp, const unsigned char **pp, long length,
+       int offset, int depth, int indent, int dump);
 static int asn1_print_info(BIO *bp, int tag, int xclass, int constructed,
-                          int indent)
+            int indent)
        {
        static const char fmt[]="%-18s";
        char str[128];
@@ -99,22 +99,21 @@ err:
        return(0);
        }
 
-int ASN1_parse(BIO *bp, const unsigned char *pp, size_t len, int indent)
+int ASN1_parse(BIO *bp, const unsigned char *pp, long len, int indent)
        {
        return(asn1_parse2(bp,&pp,len,0,0,indent,0));
        }
 
-int ASN1_parse_dump(BIO *bp, const unsigned char *pp, size_t len, int indent,
-                   int dump)
+int ASN1_parse_dump(BIO *bp, const unsigned char *pp, long len, int indent, int dump)
        {
        return(asn1_parse2(bp,&pp,len,0,0,indent,dump));
        }
 
-static int asn1_parse2(BIO *bp, const unsigned char **pp, size_t length,
-                      int offset, int depth, int indent, int dump)
+static int asn1_parse2(BIO *bp, const unsigned char **pp, long length, int offset,
+            int depth, int indent, int dump)
        {
        const unsigned char *p,*ep,*tot,*op,*opp;
-       size_t len;
+       long len;
        int tag,xclass,ret=0;
        int nl,hl,j,r;
        ASN1_OBJECT *o=NULL;
@@ -153,13 +152,13 @@ static int asn1_parse2(BIO *bp, const unsigned char **pp, size_t length,
                if (j != (V_ASN1_CONSTRUCTED | 1))
                        {
                        if (BIO_printf(bp,"d=%-2d hl=%ld l=%4ld ",
-                                      depth,(long)hl,(long)len) <= 0)
+                               depth,(long)hl,len) <= 0)
                                goto end;
                        }
                else
                        {
                        if (BIO_printf(bp,"d=%-2d hl=%ld l=inf  ",
-                                      depth,(long)hl) <= 0)
+                               depth,(long)hl) <= 0)
                                goto end;
                        }
                if (!asn1_print_info(bp,tag,xclass,j,(indent)?depth:0))
@@ -171,8 +170,7 @@ static int asn1_parse2(BIO *bp, const unsigned char **pp, size_t length,
                        if (len > length)
                                {
                                BIO_printf(bp,
-                                          "length is greater than %ld\n",
-                                          (long)length);
+                                       "length is greater than %ld\n",length);
                                ret=0;
                                goto end;
                                }
@@ -208,6 +206,8 @@ static int asn1_parse2(BIO *bp, const unsigned char **pp, size_t length,
                                (tag == V_ASN1_T61STRING) ||
                                (tag == V_ASN1_IA5STRING) ||
                                (tag == V_ASN1_VISIBLESTRING) ||
+                               (tag == V_ASN1_NUMERICSTRING) ||
+                               (tag == V_ASN1_UTF8STRING) ||
                                (tag == V_ASN1_UTCTIME) ||
                                (tag == V_ASN1_GENERALIZEDTIME))
                                {
@@ -239,7 +239,7 @@ static int asn1_parse2(BIO *bp, const unsigned char **pp, size_t length,
                                ii=d2i_ASN1_BOOLEAN(NULL,&opp,len+hl);
                                if (ii < 0)
                                        {
-                                       if (BIO_write(bp,"Bad boolean\n",12))
+                                       if (BIO_write(bp,"Bad boolean\n",12) <= 0)
                                                goto end;
                                        }
                                BIO_printf(bp,":%d",ii);