Skip to content

Commit 8997f6d

Browse files
committed
pkcs7: fix error queue leak in OpenSSL::PKCS7#detached
Only call PKCS7_get_detached() if the PKCS7 object is a signed-data. This is only useful for the content type, and leaves an error entry if called on a PKCS7 object with a different content type.
1 parent 58f0022 commit 8997f6d

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

ext/openssl/ossl_pkcs7.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,8 @@ ossl_pkcs7_get_detached(VALUE self)
510510
{
511511
PKCS7 *p7;
512512
GetPKCS7(self, p7);
513+
if (!PKCS7_type_is_signed(p7))
514+
return Qfalse;
513515
return PKCS7_get_detached(p7) ? Qtrue : Qfalse;
514516
}
515517

test/openssl/test_pkcs7.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ def test_data
265265

266266
p7 = OpenSSL::PKCS7.new(asn1)
267267
assert_equal(:data, p7.type)
268+
assert_equal(false, p7.detached)
268269
assert_equal(false, p7.detached?)
269270
# Not applicable
270271
assert_nil(p7.certificates)

0 commit comments

Comments
 (0)