Skip to content

Commit b027071

Browse files
committed
Merge branch 'PHP-7.1' into PHP-7.2
2 parents e470068 + 33382dc commit b027071

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ PHP NEWS
66
. Fixed bug #76333 (PHP built-in server does not find files if root path
77
contains special characters). (Anatol)
88

9+
- OpenSSL:
10+
. Fixed bug #76296 (openssl_pkey_get_public does not respect open_basedir).
11+
(Erik Lax, Jakub Zelenka)
12+
913
- Standard:
1014
. Fixed bug #76335 ("link(): Bad file descriptor" with non-ASCII path).
1115
(Anatol)

ext/openssl/openssl.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3809,6 +3809,9 @@ static EVP_PKEY * php_openssl_evp_from_zval(
38093809

38103810
if (Z_STRLEN_P(val) > 7 && memcmp(Z_STRVAL_P(val), "file://", sizeof("file://") - 1) == 0) {
38113811
filename = Z_STRVAL_P(val) + (sizeof("file://") - 1);
3812+
if (php_openssl_open_base_dir_chk(filename)) {
3813+
TMP_CLEAN;
3814+
}
38123815
}
38133816
/* it's an X509 file/cert of some kind, and we need to extract the data from that */
38143817
if (public_key) {
@@ -3835,9 +3838,6 @@ static EVP_PKEY * php_openssl_evp_from_zval(
38353838
BIO *in;
38363839

38373840
if (filename) {
3838-
if (php_openssl_open_base_dir_chk(filename)) {
3839-
TMP_CLEAN;
3840-
}
38413841
in = BIO_new_file(filename, PHP_OPENSSL_BIO_MODE_R(PKCS7_BINARY));
38423842
} else {
38433843
in = BIO_new_mem_buf(Z_STRVAL_P(val), (int)Z_STRLEN_P(val));

ext/openssl/tests/bug76296.phpt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
Bug #76296 openssl_pkey_get_public does not respect open_basedir
3+
--SKIPIF--
4+
<?php if (!extension_loaded("openssl")) print "skip"; ?>
5+
--FILE--
6+
<?php
7+
$dir = __DIR__ . '/bug76296_openbasedir';
8+
$pem = 'file://' . __DIR__ . '/public.key';
9+
if (!is_dir($dir)) {
10+
mkdir($dir);
11+
}
12+
13+
ini_set('open_basedir', $dir);
14+
15+
var_dump(openssl_pkey_get_public($pem));
16+
?>
17+
--EXPECTF--
18+
19+
Warning: openssl_pkey_get_public(): open_basedir restriction in effect. File(%s) is not within the allowed path(s): (%s) in %s on line %d
20+
bool(false)
21+
--CLEAN--
22+
@rmdir(__DIR__ . '/bug76296_openbasedir');

0 commit comments

Comments
 (0)