Fix the checks of X509_REVOKED_add1_ext_i2d
authorPeiwei Hu <jlu.hpw@foxmail.com>
Tue, 24 May 2022 16:09:54 +0000 (00:09 +0800)
committerTomas Mraz <tomas@openssl.org>
Thu, 23 Jun 2022 10:42:25 +0000 (12:42 +0200)
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18400)

apps/ca.c

index 23c7f05a2c98bc6351fd2f7ae0e3ee3d88983694..460099a63eeb4898489f5e5fca9b288cc4b29249 100644 (file)
--- a/apps/ca.c
+++ b/apps/ca.c
@@ -2479,18 +2479,18 @@ static int make_revoked(X509_REVOKED *rev, const char *str)
         rtmp = ASN1_ENUMERATED_new();
         if (rtmp == NULL || !ASN1_ENUMERATED_set(rtmp, reason_code))
             goto end;
-        if (!X509_REVOKED_add1_ext_i2d(rev, NID_crl_reason, rtmp, 0, 0))
+        if (X509_REVOKED_add1_ext_i2d(rev, NID_crl_reason, rtmp, 0, 0) <= 0)
             goto end;
     }
 
     if (rev && comp_time) {
-        if (!X509_REVOKED_add1_ext_i2d
-            (rev, NID_invalidity_date, comp_time, 0, 0))
+        if (X509_REVOKED_add1_ext_i2d
+            (rev, NID_invalidity_date, comp_time, 0, 0) <= 0)
             goto end;
     }
     if (rev && hold) {
-        if (!X509_REVOKED_add1_ext_i2d
-            (rev, NID_hold_instruction_code, hold, 0, 0))
+        if (X509_REVOKED_add1_ext_i2d
+            (rev, NID_hold_instruction_code, hold, 0, 0) <= 0)
             goto end;
     }