Skip to content

Commit ecfc1d0

Browse files
committed
pkcs7: fix error check of PKCS7_SIGNER_INFO_set()
This function returns <=0 on error, not only 0. This is evident by looking at the implementation where it can return a negative error here [1]. Use in OpenSSL itself also uses the <=0 check [2]. [1] https://github.com/openssl/openssl/blob/087bddcda9973671d52f94e63db32bfd6001fd1b/crypto/pkcs7/pk7_lib.c#L378-L381 [2] https://github.com/openssl/openssl/blob/087bddcda9973671d52f94e63db32bfd6001fd1b/crypto/pkcs7/pk7_lib.c#L414
1 parent 8a7c9b8 commit ecfc1d0

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

ext/openssl/ossl_pkcs7.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -979,7 +979,7 @@ ossl_pkcs7si_initialize(VALUE self, VALUE cert, VALUE key, VALUE digest)
979979
x509 = GetX509CertPtr(cert); /* NO NEED TO DUP */
980980
md = ossl_evp_md_fetch(digest, &md_holder);
981981
GetPKCS7si(self, p7si);
982-
if (!(PKCS7_SIGNER_INFO_set(p7si, x509, pkey, md)))
982+
if (PKCS7_SIGNER_INFO_set(p7si, x509, pkey, md) <= 0)
983983
ossl_raise(ePKCS7Error, "PKCS7_SIGNER_INFO_set");
984984
rb_ivar_set(self, id_md_holder, md_holder);
985985

0 commit comments

Comments
 (0)