From: PW Hu Date: Mon, 1 Nov 2021 07:00:54 +0000 (+0800) Subject: Fix incorrect return check of BN_bn2binpad X-Git-Tag: openssl-3.2.0-alpha1~3386 X-Git-Url: https://git.openssl.org/?p=openssl.git;a=commitdiff_plain;h=098f2627c8d283a518a6e6e60e7893664c7510e0 Fix incorrect return check of BN_bn2binpad Reviewed-by: Kurt Roeckx Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/16942) --- diff --git a/crypto/ec/ec_deprecated.c b/crypto/ec/ec_deprecated.c index cd2eec80b7..22ddb3660c 100644 --- a/crypto/ec/ec_deprecated.c +++ b/crypto/ec/ec_deprecated.c @@ -52,7 +52,7 @@ EC_POINT *EC_POINT_bn2point(const EC_GROUP *group, return NULL; } - if (!BN_bn2binpad(bn, buf, buf_len)) { + if (BN_bn2binpad(bn, buf, buf_len) < 0) { OPENSSL_free(buf); return NULL; } diff --git a/test/acvp_test.c b/test/acvp_test.c index 6512a6ec35..4b6632e689 100644 --- a/test/acvp_test.c +++ b/test/acvp_test.c @@ -71,7 +71,7 @@ static int pkey_get_bn_bytes(EVP_PKEY *pkey, const char *name, buf = OPENSSL_zalloc(sz); if (buf == NULL) goto err; - if (!BN_bn2binpad(bn, buf, sz)) + if (BN_bn2binpad(bn, buf, sz) <= 0) goto err; *out_len = sz; diff --git a/test/ecdsatest.c b/test/ecdsatest.c index c94d7d8dab..282b9660d3 100644 --- a/test/ecdsatest.c +++ b/test/ecdsatest.c @@ -46,7 +46,7 @@ static int fbytes(unsigned char *buf, size_t num, ossl_unused const char *name, || !TEST_true(BN_hex2bn(&tmp, numbers[fbytes_counter])) /* tmp might need leading zeros so pad it out */ || !TEST_int_le(BN_num_bytes(tmp), num) - || !TEST_true(BN_bn2binpad(tmp, buf, num))) + || !TEST_int_gt(BN_bn2binpad(tmp, buf, num), 0)) goto err; fbytes_counter = (fbytes_counter + 1) % OSSL_NELEM(numbers);