]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Return -1 properly from do_X509_REQ_verify and do_X509_verify
authorPW Hu <jlu.hpw@foxmail.com>
Tue, 9 Nov 2021 16:25:47 +0000 (00:25 +0800)
committerTomas Mraz <tomas@openssl.org>
Mon, 29 Nov 2021 12:50:43 +0000 (13:50 +0100)
Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17001)

(cherry picked from commit bc42cf51c8b2a22282bb3cdf6303e230dc7b7873)

apps/lib/apps.c

index 43c01401e8d75763a3197c98dae328b99b8b24f8..e01633c5b540b8cca24669e5030e3e9fd5c8c03c 100644 (file)
@@ -2302,23 +2302,35 @@ int do_X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const char *md,
     return rv;
 }
 
+/*
+ * do_X509_verify returns 1 if the signature is valid,
+ * 0 if the signature check fails, or -1 if error occurs.
+ */
 int do_X509_verify(X509 *x, EVP_PKEY *pkey, STACK_OF(OPENSSL_STRING) *vfyopts)
 {
     int rv = 0;
 
     if (do_x509_init(x, vfyopts) > 0)
-        rv = (X509_verify(x, pkey) > 0);
+        rv = X509_verify(x, pkey);
+    else
+        rv = -1;
     return rv;
 }
 
+/*
+ * do_X509_REQ_verify returns 1 if the signature is valid,
+ * 0 if the signature check fails, or -1 if error occurs.
+ */
 int do_X509_REQ_verify(X509_REQ *x, EVP_PKEY *pkey,
                        STACK_OF(OPENSSL_STRING) *vfyopts)
 {
     int rv = 0;
 
     if (do_x509_req_init(x, vfyopts) > 0)
-        rv = (X509_REQ_verify_ex(x, pkey,
-                                 app_get0_libctx(), app_get0_propq()) > 0);
+        rv = X509_REQ_verify_ex(x, pkey,
+                                 app_get0_libctx(), app_get0_propq());
+    else
+        rv = -1;
     return rv;
 }