Skip to content

Commit cfc659a

Browse files
committed
Merge branch 'PHP-8.1' into fix/phpgh-11950
2 parents a4b83c4 + ba07a0b commit cfc659a

27 files changed

+414
-60
lines changed

.cirrus.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ env:
44
freebsd_task:
55
name: FREEBSD_DEBUG_NTS
66
freebsd_instance:
7-
image_family: freebsd-13-0
7+
image_family: freebsd-13-2
88
env:
99
ARCH: amd64
1010
install_script:

.github/actions/apt-x64/action.yml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,3 @@ runs:
5959
libjpeg-dev \
6060
libpng-dev \
6161
libfreetype6-dev
62-
63-
mkdir /opt/oracle
64-
wget -nv https://download.oracle.com/otn_software/linux/instantclient/instantclient-basiclite-linuxx64.zip
65-
unzip instantclient-basiclite-linuxx64.zip && rm instantclient-basiclite-linuxx64.zip
66-
wget -nv https://download.oracle.com/otn_software/linux/instantclient/instantclient-sdk-linuxx64.zip
67-
unzip instantclient-sdk-linuxx64.zip && rm instantclient-sdk-linuxx64.zip
68-
mv instantclient_*_* /opt/oracle/instantclient
69-
# interferes with libldap2 headers
70-
rm /opt/oracle/instantclient/sdk/include/ldap.h
71-
# fix debug build warning: zend_signal: handler was replaced for signal (2) after startup
72-
echo DISABLE_INTERRUPT=on > /opt/oracle/instantclient/network/admin/sqlnet.ora
73-
sudo sh -c 'echo /opt/oracle/instantclient >/etc/ld.so.conf.d/oracle-instantclient.conf && ldconfig'

.github/actions/install-linux-x32/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ runs:
66
run: |
77
set -x
88
make install
9-
mkdir /etc/php.d
9+
mkdir -p /etc/php.d
1010
chmod 777 /etc/php.d
1111
echo mysqli.default_socket=/var/run/mysqld/mysqld.sock > /etc/php.d/mysqli.ini
1212
echo pdo_mysql.default_socket=/var/run/mysqld/mysqld.sock > /etc/php.d/pdo_mysql.ini

.github/actions/install-linux/action.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ runs:
66
run: |
77
set -x
88
sudo make install
9-
sudo mkdir /etc/php.d
9+
sudo mkdir -p /etc/php.d
1010
sudo chmod 777 /etc/php.d
1111
echo mysqli.default_socket=/var/run/mysqld/mysqld.sock > /etc/php.d/mysqli.ini
1212
echo pdo_mysql.default_socket=/var/run/mysqld/mysqld.sock > /etc/php.d/pdo_mysql.ini
13-
echo extension=oci8.so > /etc/php.d/oci8.ini
14-
echo extension=pdo_oci.so > /etc/php.d/pdo_oci.ini

.github/actions/setup-oracle/action.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,20 @@ runs:
1111
--name oracle \
1212
-h oracle \
1313
-d gvenzl/oracle-xe:slim
14+
15+
mkdir /opt/oracle
16+
wget -nv https://download.oracle.com/otn_software/linux/instantclient/instantclient-basiclite-linuxx64.zip
17+
unzip instantclient-basiclite-linuxx64.zip && rm instantclient-basiclite-linuxx64.zip
18+
wget -nv https://download.oracle.com/otn_software/linux/instantclient/instantclient-sdk-linuxx64.zip
19+
unzip instantclient-sdk-linuxx64.zip && rm instantclient-sdk-linuxx64.zip
20+
mv instantclient_*_* /opt/oracle/instantclient
21+
# interferes with libldap2 headers
22+
rm /opt/oracle/instantclient/sdk/include/ldap.h
23+
# fix debug build warning: zend_signal: handler was replaced for signal (2) after startup
24+
echo DISABLE_INTERRUPT=on > /opt/oracle/instantclient/network/admin/sqlnet.ora
25+
sudo sh -c 'echo /opt/oracle/instantclient >/etc/ld.so.conf.d/oracle-instantclient.conf && ldconfig'
26+
27+
sudo mkdir -p /etc/php.d
28+
sudo chmod 777 /etc/php.d
29+
echo extension=oci8.so > /etc/php.d/oci8.ini
30+
echo extension=pdo_oci.so > /etc/php.d/pdo_oci.ini

.github/nightly_matrix.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,25 @@ function get_matrix_include(array $branches) {
7878
return $jobs;
7979
}
8080

81+
function get_windows_matrix_include(array $branches) {
82+
$jobs = [];
83+
foreach ($branches as $branch) {
84+
$jobs[] = [
85+
'branch' => $branch,
86+
'x64' => true,
87+
'zts' => true,
88+
'opcache' => true,
89+
];
90+
$jobs[] = [
91+
'branch' => $branch,
92+
'x64' => false,
93+
'zts' => false,
94+
'opcache' => false,
95+
];
96+
}
97+
return $jobs;
98+
}
99+
81100
$trigger = $argv[1] ?? 'schedule';
82101
$attempt = (int) ($argv[2] ?? 1);
83102
$discard_cache = ($trigger === 'schedule' && $attempt !== 1) || $trigger === 'workflow_dispatch';
@@ -87,6 +106,8 @@ function get_matrix_include(array $branches) {
87106

88107
$branches = get_branches();
89108
$matrix_include = get_matrix_include($branches);
109+
$windows_matrix_include = get_windows_matrix_include($branches);
90110

91111
echo '::set-output name=branches::' . json_encode($branches, JSON_UNESCAPED_SLASHES) . "\n";
92112
echo '::set-output name=matrix-include::' . json_encode($matrix_include, JSON_UNESCAPED_SLASHES) . "\n";
113+
echo '::set-output name=windows-matrix-include::' . json_encode($windows_matrix_include, JSON_UNESCAPED_SLASHES) . "\n";

.github/workflows/nightly.yml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ jobs:
1111
outputs:
1212
branches: ${{ steps.set-matrix.outputs.branches }}
1313
matrix-include: ${{ steps.set-matrix.outputs.matrix-include }}
14+
windows-matrix-include: ${{ steps.set-matrix.outputs.windows-matrix-include }}
1415
steps:
1516
- uses: actions/checkout@v3
1617
with:
@@ -554,7 +555,7 @@ jobs:
554555
- name: make install
555556
run: |
556557
sudo make install
557-
sudo mkdir /etc/php.d
558+
sudo mkdir -p /etc/php.d
558559
sudo chmod 777 /etc/php.d
559560
echo mysqli.default_socket=/var/run/mysqld/mysqld.sock > /etc/php.d/mysqli.ini
560561
echo pdo_mysql.default_socket=/var/run/mysqld/mysqld.sock > /etc/php.d/pdo_mysql.ini
@@ -646,17 +647,13 @@ jobs:
646647
with:
647648
token: ${{ secrets.ACTION_MONITORING_SLACK }}
648649
WINDOWS:
650+
needs: GENERATE_MATRIX
651+
if: ${{ needs.GENERATE_MATRIX.outputs.branches != '[]' }}
649652
strategy:
650653
fail-fast: false
651654
matrix:
652-
include:
653-
- x64: true
654-
zts: true
655-
opcache: true
656-
- x64: false
657-
zts: false
658-
opcache: false
659-
name: "WINDOWS_${{ matrix.x64 && 'X64' || 'X86' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}"
655+
include: ${{ fromJson(needs.GENERATE_MATRIX.outputs.windows-matrix-include) }}
656+
name: "${{ matrix.branch.name }}_WINDOWS_${{ matrix.x64 && 'X64' || 'X86' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}"
660657
runs-on: windows-2019
661658
env:
662659
PHP_BUILD_CACHE_BASE_DIR: C:\build-cache
@@ -674,6 +671,8 @@ jobs:
674671
run: git config --global core.autocrlf false && git config --global core.eol lf
675672
- name: git checkout
676673
uses: actions/checkout@v3
674+
with:
675+
ref: ${{ matrix.branch.ref }}
677676
- name: Setup
678677
uses: ./.github/actions/setup-windows
679678
- name: Build

NEWS

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
11
PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
3-
?? ??? ????, PHP 8.1.23
3+
?? ??? ????, PHP 8.1.24
4+
5+
- Core:
6+
. Fixed bug GH-11937 (Constant ASTs containing objects). (ilutov)
7+
8+
- DOM:
9+
. Fix memory leak when setting an invalid DOMDocument encoding. (nielsdos)
10+
11+
- Iconv:
12+
. Fixed build for NetBSD which still uses the old iconv signature.
13+
(David Carlier)
14+
15+
- MySQLnd:
16+
. Fixed bug GH-10270 (Invalid error message when connection via SSL fails:
17+
"trying to connect via (null)"). (Kamil Tekiela)
18+
19+
31 Aug 2023, PHP 8.1.23
420

521
- CLI:
622
. Fixed bug GH-11716 (cli server crashes on SIGINT when compiled with
@@ -55,6 +71,10 @@ PHP NEWS
5571
. Revert behaviour of receiving SIGCHLD signals back to the behaviour
5672
before 8.1.22. (nielsdos)
5773

74+
- SPL:
75+
. Fixed bug #81992 (SplFixedArray::setSize() causes use-after-free).
76+
(nielsdos)
77+
5878
- Standard:
5979
. Prevent int overflow on $decimals in number_format. (Marc Bennewitz)
6080
. Fixed bug GH-11870 (Fix off-by-one bug when truncating tempnam prefix)

Zend/zend.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#ifndef ZEND_H
2121
#define ZEND_H
2222

23-
#define ZEND_VERSION "4.1.23-dev"
23+
#define ZEND_VERSION "4.1.24-dev"
2424

2525
#define ZEND_ENGINE_3
2626

Zend/zend_compile.c

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1458,6 +1458,35 @@ ZEND_API zend_result zend_unmangle_property_name_ex(const zend_string *name, con
14581458
}
14591459
/* }}} */
14601460

1461+
static bool array_is_const_ex(zend_array *array, uint32_t *max_checks)
1462+
{
1463+
if (zend_hash_num_elements(array) > *max_checks) {
1464+
return false;
1465+
}
1466+
*max_checks -= zend_hash_num_elements(array);
1467+
1468+
zval *element;
1469+
ZEND_HASH_FOREACH_VAL(array, element) {
1470+
if (Z_TYPE_P(element) < IS_ARRAY) {
1471+
continue;
1472+
} else if (Z_TYPE_P(element) == IS_ARRAY) {
1473+
if (!array_is_const_ex(array, max_checks)) {
1474+
return false;
1475+
}
1476+
} else {
1477+
return false;
1478+
}
1479+
} ZEND_HASH_FOREACH_END();
1480+
1481+
return true;
1482+
}
1483+
1484+
static bool array_is_const(zend_array *array)
1485+
{
1486+
uint32_t max_checks = 50;
1487+
return array_is_const_ex(array, &max_checks);
1488+
}
1489+
14611490
static bool can_ct_eval_const(zend_constant *c) {
14621491
if (ZEND_CONSTANT_FLAGS(c) & CONST_DEPRECATED) {
14631492
return 0;
@@ -1468,9 +1497,13 @@ static bool can_ct_eval_const(zend_constant *c) {
14681497
&& (CG(compiler_options) & ZEND_COMPILE_WITH_FILE_CACHE))) {
14691498
return 1;
14701499
}
1471-
if (Z_TYPE(c->value) < IS_OBJECT
1500+
if (Z_TYPE(c->value) < IS_ARRAY
14721501
&& !(CG(compiler_options) & ZEND_COMPILE_NO_CONSTANT_SUBSTITUTION)) {
14731502
return 1;
1503+
} else if (Z_TYPE(c->value) == IS_ARRAY
1504+
&& !(CG(compiler_options) & ZEND_COMPILE_NO_CONSTANT_SUBSTITUTION)
1505+
&& array_is_const(Z_ARR(c->value))) {
1506+
return 1;
14741507
}
14751508
return 0;
14761509
}
@@ -1690,7 +1723,10 @@ static bool zend_try_ct_eval_class_const(zval *zv, zend_string *class_name, zend
16901723
c = &cc->value;
16911724

16921725
/* Substitute case-sensitive (or lowercase) persistent class constants */
1693-
if (Z_TYPE_P(c) < IS_OBJECT) {
1726+
if (Z_TYPE_P(c) < IS_ARRAY) {
1727+
ZVAL_COPY_OR_DUP(zv, c);
1728+
return 1;
1729+
} else if (Z_TYPE_P(c) == IS_ARRAY && array_is_const(Z_ARR_P(c))) {
16941730
ZVAL_COPY_OR_DUP(zv, c);
16951731
return 1;
16961732
}

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ dnl Basic autoconf initialization, generation of config.nice.
1717
dnl ----------------------------------------------------------------------------
1818

1919
AC_PREREQ([2.68])
20-
AC_INIT([PHP],[8.1.23-dev],[https://github.com/php/php-src/issues],[php],[https://www.php.net])
20+
AC_INIT([PHP],[8.1.24-dev],[https://github.com/php/php-src/issues],[php],[https://www.php.net])
2121
AC_CONFIG_SRCDIR([main/php_version.h])
2222
AC_CONFIG_AUX_DIR([build])
2323
AC_PRESERVE_HELP_ORDER

ext/dom/document.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,19 +139,22 @@ int dom_document_encoding_read(dom_object *obj, zval *retval)
139139
zend_result dom_document_encoding_write(dom_object *obj, zval *newval)
140140
{
141141
xmlDoc *docp = (xmlDocPtr) dom_object_get_node(obj);
142-
zend_string *str;
143142
xmlCharEncodingHandlerPtr handler;
144143

145144
if (docp == NULL) {
146145
php_dom_throw_error(INVALID_STATE_ERR, 1);
147146
return FAILURE;
148147
}
149148

150-
str = zval_try_get_string(newval);
151-
if (UNEXPECTED(!str)) {
152-
return FAILURE;
149+
/* Typed property, can only be IS_STRING or IS_NULL. */
150+
ZEND_ASSERT(Z_TYPE_P(newval) == IS_STRING || Z_TYPE_P(newval) == IS_NULL);
151+
152+
if (Z_TYPE_P(newval) == IS_NULL) {
153+
goto invalid_encoding;
153154
}
154155

156+
zend_string *str = Z_STR_P(newval);
157+
155158
handler = xmlFindCharEncodingHandler(ZSTR_VAL(str));
156159

157160
if (handler != NULL) {
@@ -161,12 +164,14 @@ zend_result dom_document_encoding_write(dom_object *obj, zval *newval)
161164
}
162165
docp->encoding = xmlStrdup((const xmlChar *) ZSTR_VAL(str));
163166
} else {
164-
zend_value_error("Invalid document encoding");
165-
return FAILURE;
167+
goto invalid_encoding;
166168
}
167169

168-
zend_string_release_ex(str, 0);
169170
return SUCCESS;
171+
172+
invalid_encoding:
173+
zend_value_error("Invalid document encoding");
174+
return FAILURE;
170175
}
171176

172177
/* }}} */

ext/dom/tests/gh12002.phpt

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
--TEST--
2+
GH-12002 (DOMDocument::encoding memory leak with invalid encoding)
3+
--EXTENSIONS--
4+
dom
5+
--FILE--
6+
<?php
7+
8+
function make_nonconst(string $x) {
9+
// Defeat SCCP, even with inlining
10+
return str_repeat($x, random_int(1, 1));
11+
}
12+
13+
$dom = new DOMDocument();
14+
$dom->encoding = make_nonconst('utf-8');
15+
var_dump($dom->encoding);
16+
try {
17+
$dom->encoding = make_nonconst('foobar');
18+
} catch (ValueError $e) {
19+
echo $e->getMessage(), "\n";
20+
}
21+
var_dump($dom->encoding);
22+
$dom->encoding = make_nonconst('utf-16le');
23+
var_dump($dom->encoding);
24+
try {
25+
$dom->encoding = NULL;
26+
} catch (ValueError $e) {
27+
echo $e->getMessage(), "\n";
28+
}
29+
var_dump($dom->encoding);
30+
31+
?>
32+
--EXPECT--
33+
string(5) "utf-8"
34+
Invalid document encoding
35+
string(5) "utf-8"
36+
string(8) "utf-16le"
37+
Invalid document encoding
38+
string(8) "utf-16le"

0 commit comments

Comments
 (0)