Skip to content

Commit ac07b6e

Browse files
committed
Merge branch 'PHP-8.2' into PHP-8.3
2 parents f42cef6 + b2f6b6e commit ac07b6e

File tree

3 files changed

+44
-1
lines changed

3 files changed

+44
-1
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ PHP NEWS
2626
. Fixed bug GH-8143 (Crashes in zend_accel_inheritance_cache_find since
2727
upgrading to 8.1.3 due to corrupt on-disk file cache). (turchanov)
2828

29+
- OpenSSL:
30+
Fixed bug GH-12489 (Missing sigbio creation checking in openssl_cms_verify).
31+
(Jakub Zelenka)
32+
2933
- Random:
3034
. Fix Randomizer::getFloat() returning incorrect results under
3135
certain circumstances. (timwolla)

ext/openssl/openssl.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5986,12 +5986,15 @@ PHP_FUNCTION(openssl_cms_verify)
59865986
goto clean_exit;
59875987
}
59885988
if (sigfile && (flags & CMS_DETACHED)) {
5989-
sigbio = php_openssl_bio_new_file(sigfile, sigfile_len, 1, PHP_OPENSSL_BIO_MODE_R(flags));
59905989
if (encoding == ENCODING_SMIME) {
59915990
php_error_docref(NULL, E_WARNING,
59925991
"Detached signatures not possible with S/MIME encoding");
59935992
goto clean_exit;
59945993
}
5994+
sigbio = php_openssl_bio_new_file(sigfile, sigfile_len, 1, PHP_OPENSSL_BIO_MODE_R(flags));
5995+
if (sigbio == NULL) {
5996+
goto clean_exit;
5997+
}
59955998
} else {
59965999
sigbio = in; /* non-detached signature */
59976000
}

ext/openssl/tests/gh12489.phpt

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
--TEST--
2+
GH-12489: Missing sigbio creation checking in openssl_cms_verify
3+
--EXTENSIONS--
4+
openssl
5+
--FILE--
6+
<?php
7+
$infile = __DIR__ . "/plain.txt";
8+
$outfile = __DIR__ . "/out.cms";;
9+
$vout = $outfile . '.vout';
10+
11+
$privkey = "file://" . __DIR__ . "/private_rsa_1024.key";
12+
$single_cert = "file://" . __DIR__ . "/cert.crt";
13+
$assoc_headers = array("To" => "test@test", "Subject" => "testing openssl_cms_sign()");
14+
$headers = array("test@test", "testing openssl_cms_sign()");
15+
16+
var_dump(openssl_cms_sign($infile, $outfile, openssl_x509_read($single_cert), $privkey, $headers,
17+
OPENSSL_CMS_DETACHED|OPENSSL_CMS_BINARY,OPENSSL_ENCODING_PEM));
18+
ini_set('open_basedir', __DIR__);
19+
var_dump(openssl_cms_verify($infile,OPENSSL_CMS_NOVERIFY|OPENSSL_CMS_DETACHED|OPENSSL_CMS_BINARY,
20+
NULL, array(), NULL, $vout, NULL, "../test.cms", OPENSSL_ENCODING_PEM));
21+
var_dump(openssl_error_string());
22+
?>
23+
--CLEAN--
24+
<?php
25+
$outfile = __DIR__ . "/out.cms";;
26+
$vout = $outfile . '.vout';
27+
28+
@unlink($outfile);
29+
@unlink($vout);
30+
?>
31+
--EXPECTF--
32+
bool(true)
33+
34+
Warning: openssl_cms_verify(): open_basedir restriction in effect. File(%s) is not within the allowed path(s): (%s) in %s on line %d
35+
bool(false)
36+
bool(false)

0 commit comments

Comments
 (0)