Skip to content

Commit 04db3d0

Browse files
committed
Merge branch 'PHP-7.1' of git.php.net:/php-src into PHP-7.1
2 parents d6e81f0 + 73bf238 commit 04db3d0

29 files changed

+306
-61
lines changed

.appveyor.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ environment:
2323
PHP_BUILD_CACHE_BASE_DIR: c:\build-cache
2424
PHP_BUILD_OBJ_DIR: c:\obj
2525
PHP_BUILD_CACHE_SDK_DIR: c:\build-cache\sdk
26-
PHP_BUILD_SDK_BRANCH: php-sdk-2.1.3
26+
PHP_BUILD_SDK_BRANCH: php-sdk-2.1.5
2727
# ext and env setup for tests
2828
#MYSQL_TEST_PASSWD: Password12!
2929
#MYSQL_TEST_USER: root

.gdbinit

+12
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ define ____executor_globals
1616
end
1717
set $eg = ((zend_executor_globals*) (*((void ***) $tsrm_ls))[executor_globals_id-1])
1818
set $cg = ((zend_compiler_globals*) (*((void ***) $tsrm_ls))[compiler_globals_id-1])
19+
set $eg_ptr = $eg
1920
else
2021
set $eg = executor_globals
2122
set $cg = compiler_globals
23+
set $eg_ptr = (zend_executor_globals*) &executor_globals
2224
end
2325
end
2426

@@ -289,6 +291,16 @@ define ____printzv
289291
end
290292
end
291293

294+
define print_global_vars
295+
____executor_globals
296+
set $symtable = ((HashTable *)&($eg_ptr->symbol_table))
297+
print_ht $symtable
298+
end
299+
300+
document print_global_vars
301+
Prints the global variables
302+
end
303+
292304
define print_const_table
293305
set $ind = 1
294306
printf "[%p] {\n", $arg0

NEWS

+16
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,23 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? ????, PHP 7.1.19
44

5+
- CLI Server:
6+
. Fixed bug #76333 (PHP built-in server does not find files if root path
7+
contains special characters). (Anatol)
8+
9+
- OpenSSL:
10+
. Fixed bug #76296 (openssl_pkey_get_public does not respect open_basedir).
11+
(Erik Lax, Jakub Zelenka)
12+
. Fixed bug #76174 (openssl extension fails to build with LibreSSL 2.7).
13+
(Jakub Zelenka)
514

15+
- SPL:
16+
. Fixed bug #76367 (NoRewindIterator segfault 11). (Laruence)
17+
18+
- Standard:
19+
. Fixed bug #76335 ("link(): Bad file descriptor" with non-ASCII path).
20+
(Anatol)
21+
. Fixed bug #76383 (array_map on $GLOBALS returns IS_INDIRECT). (Bob)
622

723
24 May 2018, PHP 7.1.18
824

Zend/tests/bug76383.phpt

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--TEST--
2+
Bug #76383: array_map on $GLOBALS returns IS_INDIRECT
3+
--FILE--
4+
<?php
5+
6+
$a = 1;
7+
array_map(function($x) use (&$lastval) { $lastval = $x; }, $GLOBALS);
8+
var_dump(gettype($lastval), $lastval); // will contain $a
9+
10+
?>
11+
--EXPECT--
12+
string(7) "integer"
13+
int(1)

ext/bcmath/tests/bug72093-win32.phpt

+6-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ if(!extension_loaded("bcmath")) print "skip";
66
if (substr(PHP_OS, 0, 3) != 'WIN') {
77
die('skip valid only for windows');
88
}
9+
$cur = PHP_WINDOWS_VERSION_MAJOR.'.'.PHP_WINDOWS_VERSION_MINOR.'.'.PHP_WINDOWS_VERSION_BUILD;
10+
$req = "10.0.17134";
11+
if (version_compare($cur, $req) >= 0) {
12+
echo "skip Only for Windows systems < $req";
13+
}
914
?>
1015
--FILE--
1116
<?php
@@ -14,5 +19,4 @@ var_dump(bcpowmod(1, 1.2, 1, 1));
1419
?>
1520
--EXPECTF--
1621
string(1) "1"
17-
string(3) "0.0"
18-
bc math warning: non-zero scale in exponent
22+
%Astring(3) "0.0"%A

ext/bcmath/tests/bug72093.phpt

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ Bug 72093: bcpowmod accepts negative scale and corrupts _one_ definition
44
<?php
55
if(!extension_loaded("bcmath")) print "skip";
66
if (substr(PHP_OS, 0, 3) == 'WIN') {
7-
die('skip Not valid for windows');
7+
$cur = PHP_WINDOWS_VERSION_MAJOR.'.'.PHP_WINDOWS_VERSION_MINOR.'.'.PHP_WINDOWS_VERSION_BUILD;
8+
$req = "10.0.17134";
9+
if (version_compare($cur, $req) < 0) {
10+
echo "skip Compatible on Windows systems >= $req";
11+
}
812
}
913
?>
1014
--FILE--

ext/bcmath/tests/bug75178-win32.phpt

+9-6
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,19 @@ if (!extension_loaded('bcmath')) die('skip bcmath extension is not available');
66
if (substr(PHP_OS, 0, 3) != 'WIN') {
77
die('skip valid only for windows');
88
}
9+
$cur = PHP_WINDOWS_VERSION_MAJOR.'.'.PHP_WINDOWS_VERSION_MINOR.'.'.PHP_WINDOWS_VERSION_BUILD;
10+
$req = "10.0.17134";
11+
if (version_compare($cur, $req) >= 0) {
12+
echo "skip Only for Windows systems < $req";
13+
}
914
?>
1015
--FILE--
1116
<?php
1217
var_dump(bcpowmod('4.1', '4', '3', 3));
1318
var_dump(bcpowmod('4', '4', '3.1', 3));
1419
?>
1520
===DONE===
16-
--EXPECT--
17-
string(5) "1.000"
18-
string(5) "1.000"
19-
===DONE===
20-
bc math warning: non-zero scale in base
21-
bc math warning: non-zero scale in modulus
21+
--EXPECTF--
22+
%Astring(5) "1.000"
23+
%Astring(5) "1.000"
24+
===DONE===%A

ext/bcmath/tests/bug75178.phpt

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ Bug #75178 (bcpowmod() misbehaves for non-integer base or modulus)
44
<?php
55
if (!extension_loaded('bcmath')) die('skip bcmath extension is not available');
66
if (substr(PHP_OS, 0, 3) == 'WIN') {
7-
die('skip Not valid for windows');
7+
$cur = PHP_WINDOWS_VERSION_MAJOR.'.'.PHP_WINDOWS_VERSION_MINOR.'.'.PHP_WINDOWS_VERSION_BUILD;
8+
$req = "10.0.17134";
9+
if (version_compare($cur, $req) < 0) {
10+
echo "skip Compatible on Windows systems >= $req";
11+
}
812
}
913
?>
1014
--FILE--

ext/curl/tests/bug48203-win32.phpt

+3-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ echo "Ok\n";
3030
<?php @unlink(dirname(__FILE__) . '/bug48203.tmp'); ?>
3131
--EXPECTF--
3232
Warning: curl_exec(): CURLOPT_STDERR resource has gone away, resetting to stderr in %s on line %d
33-
Hello World!
34-
Hello World!Ok
3533
%A
34+
Hello World!
35+
Hello World!* Closing connection 0
36+
Ok
3637

ext/curl/tests/bug54798-win32.phpt

-1
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,3 @@ Hello World!Ok for CURLOPT_FILE
6565

6666
%AOk for CURLOPT_INFILE
6767
===DONE===
68-
%A

ext/curl/tests/server.inc

+12-6
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,23 @@ function curl_cli_server_start() {
1313
$doc_root = __DIR__;
1414
$router = "responder/get.php";
1515

16-
$descriptorspec = array(
17-
0 => STDIN,
18-
1 => STDOUT,
19-
2 => STDERR,
20-
);
21-
2216
if (substr(PHP_OS, 0, 3) == 'WIN') {
17+
$descriptorspec = array(
18+
0 => STDIN,
19+
1 => STDOUT,
20+
2 => array("pipe", "w"),
21+
);
22+
2323
$cmd = "{$php_executable} -t {$doc_root} -n -S " . PHP_CURL_SERVER_ADDRESS;
2424
$cmd .= " {$router}";
2525
$handle = proc_open(addslashes($cmd), $descriptorspec, $pipes, $doc_root, NULL, array("bypass_shell" => true, "suppress_errors" => true));
2626
} else {
27+
$descriptorspec = array(
28+
0 => STDIN,
29+
1 => STDOUT,
30+
2 => STDERR,
31+
);
32+
2733
$cmd = "exec {$php_executable} -t {$doc_root} -n -S " . PHP_CURL_SERVER_ADDRESS;
2834
$cmd .= " {$router}";
2935
$cmd .= " 2>/dev/null";

ext/opcache/tests/php_cli_server.inc

+12-6
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,22 @@ function php_cli_server_start($ini = "") {
77
$php_executable = getenv('TEST_PHP_EXECUTABLE');
88
$doc_root = __DIR__;
99

10-
$descriptorspec = array(
11-
0 => STDIN,
12-
1 => STDOUT,
13-
2 => STDERR,
14-
);
15-
1610
if (substr(PHP_OS, 0, 3) == 'WIN') {
11+
$descriptorspec = array(
12+
0 => STDIN,
13+
1 => STDOUT,
14+
2 => array("pipe", "w"),
15+
);
16+
1717
$cmd = "{$php_executable} -t {$doc_root} $ini -S " . PHP_CLI_SERVER_ADDRESS;
1818
$handle = proc_open(addslashes($cmd), $descriptorspec, $pipes, $doc_root, NULL, array("bypass_shell" => true, "suppress_errors" => true));
1919
} else {
20+
$descriptorspec = array(
21+
0 => STDIN,
22+
1 => STDOUT,
23+
2 => STDERR,
24+
);
25+
2026
$cmd = "exec {$php_executable} -t {$doc_root} $ini -S " . PHP_CLI_SERVER_ADDRESS . " 2>/dev/null";
2127
$handle = proc_open($cmd, $descriptorspec, $pipes, $doc_root);
2228
}

ext/openssl/openssl.c

+11-11
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
#ifdef HAVE_OPENSSL_MD2_H
7474
#define OPENSSL_ALGO_MD2 4
7575
#endif
76-
#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined (LIBRESSL_VERSION_NUMBER)
76+
#if PHP_OPENSSL_API_VERSION < 0x10100
7777
#define OPENSSL_ALGO_DSS1 5
7878
#endif
7979
#define OPENSSL_ALGO_SHA224 6
@@ -560,7 +560,7 @@ ZEND_GET_MODULE(openssl)
560560
#endif
561561

562562
/* {{{ OpenSSL compatibility functions and macros */
563-
#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined (LIBRESSL_VERSION_NUMBER)
563+
#if PHP_OPENSSL_API_VERSION < 0x10100
564564
#define EVP_PKEY_get0_RSA(_pkey) _pkey->pkey.rsa
565565
#define EVP_PKEY_get0_DH(_pkey) _pkey->pkey.dh
566566
#define EVP_PKEY_get0_DSA(_pkey) _pkey->pkey.dsa
@@ -677,7 +677,7 @@ static const unsigned char *ASN1_STRING_get0_data(const ASN1_STRING *asn1)
677677
return M_ASN1_STRING_data(asn1);
678678
}
679679

680-
#if OPENSSL_VERSION_NUMBER < 0x10002000L || defined (LIBRESSL_VERSION_NUMBER)
680+
#if PHP_OPENSSL_API_VERSION < 0x10002
681681

682682
static int X509_get_signature_nid(const X509 *x)
683683
{
@@ -1237,7 +1237,7 @@ static void php_openssl_dispose_config(struct php_x509_request * req) /* {{{ */
12371237
}
12381238
/* }}} */
12391239

1240-
#if defined(PHP_WIN32) || (OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER))
1240+
#if defined(PHP_WIN32) || PHP_OPENSSL_API_VERSION >= 0x10100
12411241
#define PHP_OPENSSL_RAND_ADD_TIME() ((void) 0)
12421242
#else
12431243
#define PHP_OPENSSL_RAND_ADD_TIME() php_openssl_rand_add_timeval()
@@ -1324,7 +1324,7 @@ static EVP_MD * php_openssl_get_evp_md_from_algo(zend_long algo) { /* {{{ */
13241324
mdtype = (EVP_MD *) EVP_md2();
13251325
break;
13261326
#endif
1327-
#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined (LIBRESSL_VERSION_NUMBER)
1327+
#if PHP_OPENSSL_API_VERSION < 0x10100
13281328
case OPENSSL_ALGO_DSS1:
13291329
mdtype = (EVP_MD *) EVP_dss1();
13301330
break;
@@ -1450,7 +1450,7 @@ PHP_MINIT_FUNCTION(openssl)
14501450
#ifdef HAVE_OPENSSL_MD2_H
14511451
REGISTER_LONG_CONSTANT("OPENSSL_ALGO_MD2", OPENSSL_ALGO_MD2, CONST_CS|CONST_PERSISTENT);
14521452
#endif
1453-
#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined (LIBRESSL_VERSION_NUMBER)
1453+
#if PHP_OPENSSL_API_VERSION < 0x10100
14541454
REGISTER_LONG_CONSTANT("OPENSSL_ALGO_DSS1", OPENSSL_ALGO_DSS1, CONST_CS|CONST_PERSISTENT);
14551455
#endif
14561456
REGISTER_LONG_CONSTANT("OPENSSL_ALGO_SHA224", OPENSSL_ALGO_SHA224, CONST_CS|CONST_PERSISTENT);
@@ -3620,7 +3620,7 @@ PHP_FUNCTION(openssl_csr_get_public_key)
36203620
RETURN_FALSE;
36213621
}
36223622

3623-
#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
3623+
#if PHP_OPENSSL_API_VERSION >= 0x10100
36243624
/* Due to changes in OpenSSL 1.1 related to locking when decoding CSR,
36253625
* the pub key is not changed after assigning. It means if we pass
36263626
* a private key, it will be returned including the private part.
@@ -3631,7 +3631,7 @@ PHP_FUNCTION(openssl_csr_get_public_key)
36313631
/* Retrieve the public key from the CSR */
36323632
tpubkey = X509_REQ_get_pubkey(csr);
36333633

3634-
#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
3634+
#if PHP_OPENSSL_API_VERSION >= 0x10100
36353635
/* We need to free the CSR as it was duplicated */
36363636
X509_REQ_free(csr);
36373637
#endif
@@ -3785,6 +3785,9 @@ static EVP_PKEY * php_openssl_evp_from_zval(
37853785

37863786
if (Z_STRLEN_P(val) > 7 && memcmp(Z_STRVAL_P(val), "file://", sizeof("file://") - 1) == 0) {
37873787
filename = Z_STRVAL_P(val) + (sizeof("file://") - 1);
3788+
if (php_openssl_open_base_dir_chk(filename)) {
3789+
TMP_CLEAN;
3790+
}
37883791
}
37893792
/* it's an X509 file/cert of some kind, and we need to extract the data from that */
37903793
if (public_key) {
@@ -3811,9 +3814,6 @@ static EVP_PKEY * php_openssl_evp_from_zval(
38113814
BIO *in;
38123815

38133816
if (filename) {
3814-
if (php_openssl_open_base_dir_chk(filename)) {
3815-
TMP_CLEAN;
3816-
}
38173817
in = BIO_new_file(filename, PHP_OPENSSL_BIO_MODE_R(PKCS7_BINARY));
38183818
} else {
38193819
in = BIO_new_mem_buf(Z_STRVAL_P(val), (int)Z_STRLEN_P(val));

ext/openssl/php_openssl.h

+19
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,25 @@ extern zend_module_entry openssl_module_entry;
2929
#include "php_version.h"
3030
#define PHP_OPENSSL_VERSION PHP_VERSION
3131

32+
#include <openssl/opensslv.h>
33+
#if defined(LIBRESSL_VERSION_NUMBER)
34+
/* LibreSSL version check */
35+
#if LIBRESSL_VERSION_NUMBER < 0x20700000L
36+
#define PHP_OPENSSL_API_VERSION 0x10001
37+
#else
38+
#define PHP_OPENSSL_API_VERSION 0x10100
39+
#endif
40+
#else
41+
/* OpenSSL version check */
42+
#if OPENSSL_VERSION_NUMBER < 0x10002000L
43+
#define PHP_OPENSSL_API_VERSION 0x10001
44+
#elif OPENSSL_VERSION_NUMBER < 0x10100000L
45+
#define PHP_OPENSSL_API_VERSION 0x10002
46+
#else
47+
#define PHP_OPENSSL_API_VERSION 0x10100
48+
#endif
49+
#endif
50+
3251
#define OPENSSL_RAW_DATA 1
3352
#define OPENSSL_ZERO_PADDING 2
3453
#define OPENSSL_DONT_ZERO_PAD_KEY 4

ext/openssl/tests/bug76296.phpt

+22
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)