From 2232e262bffb9330946760fe3635e6531b909df2 Mon Sep 17 00:00:00 2001 From: "Dr. Stephen Henson" Date: Wed, 13 Nov 2002 00:40:51 +0000 Subject: [PATCH] Fix memory leak in s2i_ASN_INTEGER and return an error if any invalid characters are present. --- crypto/x509v3/v3_utl.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crypto/x509v3/v3_utl.c b/crypto/x509v3/v3_utl.c index 283e943e46..1f0db94776 100644 --- a/crypto/x509v3/v3_utl.c +++ b/crypto/x509v3/v3_utl.c @@ -156,11 +156,11 @@ ASN1_INTEGER *s2i_ASN1_INTEGER(X509V3_EXT_METHOD *method, char *value) ASN1_INTEGER *aint; int isneg, ishex; int ret; - bn = BN_new(); if (!value) { X509V3err(X509V3_F_S2I_ASN1_INTEGER,X509V3_R_INVALID_NULL_VALUE); return 0; } + bn = BN_new(); if (value[0] == '-') { value++; isneg = 1; @@ -174,7 +174,8 @@ ASN1_INTEGER *s2i_ASN1_INTEGER(X509V3_EXT_METHOD *method, char *value) if (ishex) ret = BN_hex2bn(&bn, value); else ret = BN_dec2bn(&bn, value); - if (!ret) { + if (!ret || value[ret]) { + BN_free(bn); X509V3err(X509V3_F_S2I_ASN1_INTEGER,X509V3_R_BN_DEC2BN_ERROR); return 0; } -- 2.25.1