Fix the erroneous checks of EVP_PKEY_CTX_set_group_name
authorPeiwei Hu <jlu.hpw@foxmail.com>
Tue, 24 May 2022 15:27:49 +0000 (23:27 +0800)
committerTomas Mraz <tomas@openssl.org>
Thu, 2 Jun 2022 09:06:35 +0000 (11:06 +0200)
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18399)

crypto/cms/cms_ec.c
ssl/s3_lib.c
test/evp_extra_test.c

index 082fb5c4c9fe6b038f857e982b71f1248ba9aaf1..be9c6ff89333a619028ae7b2c80d19fd09a75706 100644 (file)
@@ -48,7 +48,7 @@ static EVP_PKEY *pkey_type2param(int ptype, const void *pval,
         if (pctx == NULL || EVP_PKEY_paramgen_init(pctx) <= 0)
             goto err;
         if (OBJ_obj2txt(groupname, sizeof(groupname), poid, 0) <= 0
-                || !EVP_PKEY_CTX_set_group_name(pctx, groupname)) {
+                || EVP_PKEY_CTX_set_group_name(pctx, groupname) <= 0) {
             ERR_raise(ERR_LIB_CMS, CMS_R_DECODE_ERROR);
             goto err;
         }
index 5b9d21b566b0908b6fda0080767f5cdacb945aea..1091b8831d1da7e81ee23f48346d662ce3cbead2 100644 (file)
@@ -4720,7 +4720,7 @@ EVP_PKEY *ssl_generate_pkey_group(SSL *s, uint16_t id)
         SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_EVP_LIB);
         goto err;
     }
-    if (!EVP_PKEY_CTX_set_group_name(pctx, ginf->realname)) {
+    if (EVP_PKEY_CTX_set_group_name(pctx, ginf->realname) <= 0) {
         SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_EVP_LIB);
         goto err;
     }
@@ -4754,7 +4754,7 @@ EVP_PKEY *ssl_generate_param_group(SSL *s, uint16_t id)
         goto err;
     if (EVP_PKEY_paramgen_init(pctx) <= 0)
         goto err;
-    if (!EVP_PKEY_CTX_set_group_name(pctx, ginf->realname)) {
+    if (EVP_PKEY_CTX_set_group_name(pctx, ginf->realname) <= 0) {
         SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_EVP_LIB);
         goto err;
     }
index b7f2fe7e2837a8ed42d3a3664da044e813688dee..4518271a823a07a9bd169b7168aeb04b40460101 100644 (file)
@@ -1759,7 +1759,7 @@ static int test_EC_keygen_with_enc(int idx)
     /* Create key parameters */
     if (!TEST_ptr(pctx = EVP_PKEY_CTX_new_from_name(testctx, "EC", NULL))
         || !TEST_int_gt(EVP_PKEY_paramgen_init(pctx), 0)
-        || !TEST_true(EVP_PKEY_CTX_set_group_name(pctx, "P-256"))
+        || !TEST_int_gt(EVP_PKEY_CTX_set_group_name(pctx, "P-256"), 0)
         || !TEST_true(EVP_PKEY_CTX_set_ec_param_enc(pctx, enc))
         || !TEST_true(EVP_PKEY_paramgen(pctx, &params))
         || !TEST_ptr(params))