asn1/t_x509.c: fix serial number print, harmonize with a_int.c [from HEAD].

PR: 2675
Submitted by: Annie Yousar
This commit is contained in:
Andy Polyakov 2012-01-11 21:12:47 +00:00
parent 397977726c
commit 958e6a75a1
2 changed files with 4 additions and 4 deletions

View File

@ -386,8 +386,8 @@ long ASN1_INTEGER_get(const ASN1_INTEGER *a)
if (a->length > (int)sizeof(long)) if (a->length > (int)sizeof(long))
{ {
/* hmm... a bit ugly */ /* hmm... a bit ugly, return all ones */
return(0xffffffffL); return -1;
} }
if (a->data == NULL) if (a->data == NULL)
return 0; return 0;

View 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; if (BIO_write(bp," Serial Number:",22) <= 0) goto err;
bs=X509_get_serialNumber(x); bs=X509_get_serialNumber(x);
if (bs->length <= 4) if (bs->length <= sizeof(long))
{ {
l=ASN1_INTEGER_get(bs); l=ASN1_INTEGER_get(bs);
if (l < 0) if (bs->type == V_ASN1_NEG_INTEGER)
{ {
l= -l; l= -l;
neg="-"; neg="-";