From: Tomas Mraz Date: Wed, 12 Nov 2025 15:59:46 +0000 (+0100) Subject: Add negative test for PKCS12_SAFEBAG_get0_bag*() functions X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=afee2ea367edb590d8a71eb34f520bb355401047;p=thirdparty%2Fopenssl.git Add negative test for PKCS12_SAFEBAG_get0_bag*() functions Reviewed-by: Paul Dale Reviewed-by: Dmitry Belyavskiy (Merged from https://github.com/openssl/openssl/pull/29128) (cherry picked from commit 930a9502d15aabde8c774ebf45834c2c135047c0) --- 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);