]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Fix incomplete check on X509V3_add1_i2d()
authorndossche <niels.dossche@ugent.be>
Fri, 27 Jan 2023 14:43:42 +0000 (15:43 +0100)
committerPauli <pauli@openssl.org>
Tue, 31 Jan 2023 00:05:51 +0000 (11:05 +1100)
X509V3_add1_i2d() can return both -1 and 0 as an error code. This check
only checked for 0. Change it into <= 0 to also catch the -1 error code.

CLA: trivial

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20157)

crypto/ocsp/ocsp_ext.c

index c2b61bd4f2c43a738541104667b221f395339cb6..753b30ce47a792d9f760417a37143715b8647152 100644 (file)
@@ -268,8 +268,8 @@ static int ocsp_add1_nonce(STACK_OF(X509_EXTENSION) **exts,
         memcpy(tmpval, val, len);
     else if (RAND_bytes(tmpval, len) <= 0)
         goto err;
-    if (!X509V3_add1_i2d(exts, NID_id_pkix_OCSP_Nonce,
-                         &os, 0, X509V3_ADD_REPLACE))
+    if (X509V3_add1_i2d(exts, NID_id_pkix_OCSP_Nonce,
+                         &os, 0, X509V3_ADD_REPLACE) <= 0)
         goto err;
     ret = 1;
  err: