aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomas Mraz <[email protected]>2025-11-12 16:59:46 +0100
committerTomas Mraz <[email protected]>2025-11-14 18:32:31 +0100
commitafee2ea367edb590d8a71eb34f520bb355401047 (patch)
tree02cc73dd9e85978c7f83f113c39f93ff81fe6c28
parentAdd safety checks to PKCS12_SAFEBAG_get0_bag*() functions (diff)
downloadopenssl-afee2ea367edb590d8a71eb34f520bb355401047.tar.gz
openssl-afee2ea367edb590d8a71eb34f520bb355401047.zip
Add negative test for PKCS12_SAFEBAG_get0_bag*() functions
Reviewed-by: Paul Dale <[email protected]> Reviewed-by: Dmitry Belyavskiy <[email protected]> (Merged from https://github.com/openssl/openssl/pull/29128) (cherry picked from commit 930a9502d15aabde8c774ebf45834c2c135047c0)
-rw-r--r--test/helpers/pkcs12.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/helpers/pkcs12.c b/test/helpers/pkcs12.c
index c2969c21d05..60e72ccf768 100644
--- a/test/helpers/pkcs12.c
+++ b/test/helpers/pkcs12.c
@@ -573,6 +573,11 @@ void check_certbag(PKCS12_BUILDER *pb, const unsigned char *bytes, int len,
pb->success = 0;
goto err;
}
+ if (!TEST_ptr_null(PKCS12_SAFEBAG_get0_bag_obj(bag))) {
+ pb->success = 0;
+ goto err;
+ }
+
ref_x509 = load_cert_asn1(bytes, len);
if (!TEST_false(X509_cmp(x509, ref_x509)))
pb->success = 0;
@@ -634,6 +639,10 @@ void check_keybag(PKCS12_BUILDER *pb, const unsigned char *bytes, int len,
pb->success = 0;
goto err;
}
+ if (!TEST_ptr_null(PKCS12_SAFEBAG_get0_bag_type(bag))) {
+ pb->success = 0;
+ goto err;
+ }
/* PKEY compare returns 1 for match */
ref_pkey = load_pkey_asn1(bytes, len);