PR: 2742
[oweals/openssl.git] / crypto / asn1 / t_x509.c
index d7eab16339428f5e09bda947003bce081d8681e4..edbb39a02f7a5749e183de368b5bf8f34b4226f1 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 <= (int)sizeof(long))
                        {
                        l=ASN1_INTEGER_get(bs);
-                       if (l < 0)
+                       if (bs->type == V_ASN1_NEG_INTEGER)
                                {
                                l= -l;
                                neg="-";
@@ -168,12 +168,16 @@ int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags, unsigned long cflag)
 
        if(!(cflag & X509_FLAG_NO_SIGNAME))
                {
+               if(X509_signature_print(bp, x->sig_alg, NULL) <= 0)
+                       goto err;
+#if 0
                if (BIO_printf(bp,"%8sSignature Algorithm: ","") <= 0) 
                        goto err;
                if (i2a_ASN1_OBJECT(bp, ci->signature->algorithm) <= 0)
                        goto err;
                if (BIO_puts(bp, "\n") <= 0)
                        goto err;
+#endif
                }
 
        if(!(cflag & X509_FLAG_NO_ISSUER))
@@ -327,8 +331,11 @@ int X509_signature_print(BIO *bp, X509_ALGOR *sigalg, ASN1_STRING *sig)
                                return ameth->sig_print(bp, sigalg, sig, 9, 0);
                        }
                }
-
-       return X509_signature_dump(bp, sig, 9);
+       if (sig)
+               return X509_signature_dump(bp, sig, 9);
+       else if (BIO_puts(bp, "\n") <= 0)
+               return 0;
+       return 1;
 }
 
 int ASN1_STRING_print(BIO *bp, const ASN1_STRING *v)