From 58c03e3b9225fe1a8e3f6b8c23c45b33e26fedb5 Mon Sep 17 00:00:00 2001 From: huangqinjin Date: Sat, 7 May 2016 00:50:22 +0800 Subject: [PATCH] fix BN_hex2bn()/BN_dec2bn() memory leak Reviewed-by: Kurt Roeckx Reviewed-by: Matt Caswell --- crypto/bn/bn_print.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crypto/bn/bn_print.c b/crypto/bn/bn_print.c index 8d06405ab6..78589dba5b 100644 --- a/crypto/bn/bn_print.c +++ b/crypto/bn/bn_print.c @@ -139,7 +139,7 @@ int BN_hex2bn(BIGNUM **bn, const char *a) for (i = 0; i <= (INT_MAX/4) && isxdigit((unsigned char)a[i]); i++) continue; - if (i > INT_MAX/4) + if (i == 0 || i > INT_MAX/4) goto err; num = i + neg; @@ -209,7 +209,7 @@ int BN_dec2bn(BIGNUM **bn, const char *a) for (i = 0; i <= (INT_MAX/4) && isdigit((unsigned char)a[i]); i++) continue; - if (i > INT_MAX/4) + if (i == 0 || i > INT_MAX/4) goto err; num = i + neg; -- 2.25.1