File tree Expand file tree Collapse file tree 3 files changed +29
-3
lines changed Expand file tree Collapse file tree 3 files changed +29
-3
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,10 @@ PHP NEWS
6
6
. Fixed bug #76333 (PHP built-in server does not find files if root path
7
7
contains special characters). (Anatol)
8
8
9
+ - OpenSSL:
10
+ . Fixed bug #76296 (openssl_pkey_get_public does not respect open_basedir).
11
+ (Erik Lax, Jakub Zelenka)
12
+
9
13
- Standard:
10
14
. Fixed bug #76335 ("link(): Bad file descriptor" with non-ASCII path).
11
15
(Anatol)
Original file line number Diff line number Diff line change @@ -3809,6 +3809,9 @@ static EVP_PKEY * php_openssl_evp_from_zval(
3809
3809
3810
3810
if (Z_STRLEN_P (val ) > 7 && memcmp (Z_STRVAL_P (val ), "file://" , sizeof ("file://" ) - 1 ) == 0 ) {
3811
3811
filename = Z_STRVAL_P (val ) + (sizeof ("file://" ) - 1 );
3812
+ if (php_openssl_open_base_dir_chk (filename )) {
3813
+ TMP_CLEAN ;
3814
+ }
3812
3815
}
3813
3816
/* it's an X509 file/cert of some kind, and we need to extract the data from that */
3814
3817
if (public_key ) {
@@ -3835,9 +3838,6 @@ static EVP_PKEY * php_openssl_evp_from_zval(
3835
3838
BIO * in ;
3836
3839
3837
3840
if (filename ) {
3838
- if (php_openssl_open_base_dir_chk (filename )) {
3839
- TMP_CLEAN ;
3840
- }
3841
3841
in = BIO_new_file (filename , PHP_OPENSSL_BIO_MODE_R (PKCS7_BINARY ));
3842
3842
} else {
3843
3843
in = BIO_new_mem_buf (Z_STRVAL_P (val ), (int )Z_STRLEN_P (val ));
Original file line number Diff line number Diff line change
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');
You can’t perform that action at this time.
0 commit comments