]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Detect segfault in the pkeyutl test
authorMatt Caswell <matt@openssl.org>
Tue, 1 Apr 2025 09:32:00 +0000 (10:32 +0100)
committerTomas Mraz <tomas@openssl.org>
Wed, 2 Apr 2025 15:28:29 +0000 (17:28 +0200)
Some tests are expected to fail in the pkeyutl test. However, if a segfault
occurs then that counts as a failure and the test passes. A segfault should
never be a "pass".

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27228)

test/recipes/20-test_pkeyutl.t

index 2dc22e0c6e9996a914bf99a895fad9803a84150e..31e46c6d99b070e08953d7b6ed168779c84151e9 100644 (file)
@@ -11,7 +11,7 @@ use warnings;
 
 use File::Spec;
 use File::Basename;
-use OpenSSL::Test qw/:DEFAULT srctop_file ok_nofips/;
+use OpenSSL::Test qw/:DEFAULT srctop_file ok_nofips with/;
 use OpenSSL::Test::Utils;
 use File::Compare qw/compare_text compare/;
 
@@ -68,9 +68,13 @@ SKIP: {
                   '-inkey', srctop_file('test', 'certs', 'server-ed25519-cert.pem'),
                   '-sigfile', 'Ed25519.sig']))),
                   "Verify an Ed25519 signature against a piece of data");
-    ok(!run(app(([ 'openssl', 'pkeyutl', '-verifyrecover', '-in', 'Ed25519.sig',
-                   '-inkey', srctop_file('test', 'certs', 'server-ed25519-key.pem')]))),
-       "Cannot use -verifyrecover with EdDSA");
+    #Check for failure return code
+    with({ exit_checker => sub { return shift == 1; } },
+        sub {
+            ok(run(app(([ 'openssl', 'pkeyutl', '-verifyrecover', '-in', 'Ed25519.sig',
+                          '-inkey', srctop_file('test', 'certs', 'server-ed25519-key.pem')]))),
+               "Cannot use -verifyrecover with EdDSA");
+        });
 
     # Ed448
     ok(run(app(([ 'openssl', 'pkeyutl', '-sign', '-in',
@@ -123,8 +127,12 @@ sub tsignverify {
              '-out', $sigfile,
              '-in', $data_to_sign);
     push(@args, @extraopts);
-    ok(!run(app([@args])),
-       $testtext.": Checking that mismatching keyform fails");
+    #Check for failure return code
+    with({ exit_checker => sub { return shift == 1; } },
+        sub {
+            ok(run(app([@args])),
+               $testtext.": Checking that mismatching keyform fails");
+        });
 
     @args = ('openssl', 'pkeyutl', '-verify',
              '-inkey', $privkey,
@@ -148,8 +156,12 @@ sub tsignverify {
              '-sigfile', $sigfile,
              '-in', $other_data);
     push(@args, @extraopts);
-    ok(!run(app([@args])),
-       $testtext.": Expect failure verifying mismatching data");
+    #Check for failure return code
+    with({ exit_checker => sub { return shift == 1; } },
+        sub {
+            ok(run(app([@args])),
+               $testtext.": Expect failure verifying mismatching data");
+        });
 }
 
 SKIP: {