]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Fix incomplete check on CMS_SharedInfo_encode
authorndossche <niels.dossche@ugent.be>
Tue, 31 Jan 2023 15:30:26 +0000 (16:30 +0100)
committerTomas Mraz <tomas@openssl.org>
Wed, 8 Feb 2023 15:57:58 +0000 (16:57 +0100)
CMS_SharedInfo_encode() can also return a negative error value, but this
is not checked in the current check, only the zero error return value is
covered. A previous PR [1] fixed the other caller's check of
CMS_SharedInfo_encode in this file, but it seems like this place was
missed. Fix it by changing the check to <= 0.

[1] https://github.com/openssl/openssl/pull/12628/commits/a752fc4da5e1dfd5b3a730d95272c2e2b0c48f1a

CLA: trivial

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20181)

crypto/cms/cms_ec.c

index 808b3bf1ae2350770be483e0d89d51bdf075fb58..896eda61da7062e836be212d915dede97cf91124 100644 (file)
@@ -346,7 +346,7 @@ static int ecdh_cms_encrypt(CMS_RecipientInfo *ri)
 
     penclen = CMS_SharedInfo_encode(&penc, wrap_alg, ukm, keylen);
 
-    if (penclen == 0)
+    if (penclen <= 0)
         goto err;
 
     if (EVP_PKEY_CTX_set0_ecdh_kdf_ukm(pctx, penc, penclen) <= 0)