asn1/t_x509.c: fix serial number print, harmonize with a_int.c.
authorAndy Polyakov <appro@openssl.org>
Wed, 11 Jan 2012 21:12:22 +0000 (21:12 +0000)
committerAndy Polyakov <appro@openssl.org>
Wed, 11 Jan 2012 21:12:22 +0000 (21:12 +0000)
PR: 2675
Submitted by: Annie Yousar

crypto/asn1/a_int.c
crypto/asn1/t_x509.c

index 3348b87..ad0d250 100644 (file)
@@ -386,8 +386,8 @@ long ASN1_INTEGER_get(const ASN1_INTEGER *a)
        
        if (a->length > (int)sizeof(long))
                {
-               /* hmm... a bit ugly */
-               return(0xffffffffL);
+               /* hmm... a bit ugly, return all ones */
+               return -1;
                }
        if (a->data == NULL)
                return 0;
index db88f3a..4f5d28f 100644 (file)
@@ -138,10 +138,10 @@ int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags, unsigned long cflag)
                if (BIO_write(bp,"        Serial Number:",22) <= 0) goto err;
 
                bs=X509_get_serialNumber(x);
-               if (bs->length <= 4)
+               if (bs->length <= sizeof(long))
                        {
                        l=ASN1_INTEGER_get(bs);
-                       if (l < 0)
+                       if (bs->type == V_ASN1_NEG_INTEGER)
                                {
                                l= -l;
                                neg="-";