Compare commits
9
Commits
9ca1942a50
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
50c5104130 | ||
|
|
5494ccc9df | ||
|
|
7b6bb066dc | ||
|
|
e73064d2b0 | ||
|
|
1e4b13746e | ||
|
|
06bea0b16f | ||
|
|
6a3b03fd9f | ||
|
|
f19ee454d1 | ||
|
|
837decf4c0 |
No files matched your search
+162
-24
@@ -671,14 +671,23 @@ echo "Insert User/Group for apache daemon (httpd)."
|
|||||||
echo ""
|
echo ""
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
|
## - User and group are written into the pool configs and into
|
||||||
|
## - /etc/tmpfiles.d/php-fpm.conf, so only accept names that really exist
|
||||||
|
## - on this system (a stray character like '#' breaks /run/php at boot).
|
||||||
|
## -
|
||||||
HTTPD_USER=
|
HTTPD_USER=
|
||||||
while [ "X$HTTPD_USER" = "X" ]
|
while [ "X$HTTPD_USER" = "X" ]
|
||||||
do
|
do
|
||||||
echononl "apache user [${_HTTPD_USER}]: "
|
echononl "apache user [${_HTTPD_USER}]: "
|
||||||
read HTTPD_USER
|
read -r HTTPD_USER
|
||||||
|
HTTPD_USER="$(echo "$HTTPD_USER" | tr -d '[:space:]')"
|
||||||
if [ "X$HTTPD_USER" = "X" ]; then
|
if [ "X$HTTPD_USER" = "X" ]; then
|
||||||
HTTPD_USER=$_HTTPD_USER
|
HTTPD_USER=$_HTTPD_USER
|
||||||
fi
|
fi
|
||||||
|
if ! getent passwd "$HTTPD_USER" > /dev/null 2>&1 ; then
|
||||||
|
echo -e "\n\t\033[31mUser '$HTTPD_USER' does not exist on this system !! Try again..\033[m\n"
|
||||||
|
HTTPD_USER=
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
if [ -z "$_HTTPD_GROUP" ]; then
|
if [ -z "$_HTTPD_GROUP" ]; then
|
||||||
if [ "$HTTPD_USER" = "nobody" ]; then
|
if [ "$HTTPD_USER" = "nobody" ]; then
|
||||||
@@ -687,13 +696,19 @@ if [ -z "$_HTTPD_GROUP" ]; then
|
|||||||
_HTTPD_GROUP=$HTTPD_USER
|
_HTTPD_GROUP=$HTTPD_USER
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
HTTPD_GROUP=
|
||||||
while [ "X$HTTPD_GROUP" = "X" ]
|
while [ "X$HTTPD_GROUP" = "X" ]
|
||||||
do
|
do
|
||||||
echononl "apache group [$_HTTPD_GROUP]: "
|
echononl "apache group [$_HTTPD_GROUP]: "
|
||||||
read HTTPD_GROUP
|
read -r HTTPD_GROUP
|
||||||
|
HTTPD_GROUP="$(echo "$HTTPD_GROUP" | tr -d '[:space:]')"
|
||||||
if [ "X$HTTPD_GROUP" = "X" ]; then
|
if [ "X$HTTPD_GROUP" = "X" ]; then
|
||||||
HTTPD_GROUP=$_HTTPD_GROUP
|
HTTPD_GROUP=$_HTTPD_GROUP
|
||||||
fi
|
fi
|
||||||
|
if ! getent group "$HTTPD_GROUP" > /dev/null 2>&1 ; then
|
||||||
|
echo -e "\n\t\033[31mGroup '$HTTPD_GROUP' does not exist on this system !! Try again..\033[m\n"
|
||||||
|
HTTPD_GROUP=
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
_PHP_FPM_USER=$HTTPD_USER
|
_PHP_FPM_USER=$HTTPD_USER
|
||||||
@@ -6380,9 +6395,16 @@ fi
|
|||||||
# -
|
# -
|
||||||
# - Security fix: if it fails, abort - never build PHP 5.6 without it.
|
# - Security fix: if it fails, abort - never build PHP 5.6 without it.
|
||||||
# -
|
# -
|
||||||
|
# - NOT for 5.6.40: there 'php-5.6.40-sury-105.patch' (omega8cc/boa, see
|
||||||
|
# - below) brings its own backport of the CVE-2026-109618/109619 fix - the
|
||||||
|
# - same fix boa uses for 7.4/8.x (session upload progress disabled,
|
||||||
|
# - array_init_singleton, zend_mm_safe_error_ex, MIME header filter,
|
||||||
|
# - max_multipart_body_parts, ...). Both patches change the same code and
|
||||||
|
# - exclude each other: with this patch applied, sury-105 and xlts-2 fail.
|
||||||
|
# -
|
||||||
_patch_file="php-5.6-enhanced-universal.patch"
|
_patch_file="php-5.6-enhanced-universal.patch"
|
||||||
echononl "\tApply ${_patch_file} (php2shell)"
|
echononl "\tApply ${_patch_file} (php2shell)"
|
||||||
if [[ "$PHP_MAIN_VERSION" = "5.6" ]]; then
|
if [[ "$PHP_MAIN_VERSION" = "5.6" ]] && [[ "$VERSION" != "5.6.40" ]]; then
|
||||||
if [[ -f "${_srcdir}/${_patch_file}" ]] ; then
|
if [[ -f "${_srcdir}/${_patch_file}" ]] ; then
|
||||||
patch -d $_builddir -p1 < ${_srcdir}/${_patch_file} > $tmp_err_msg 2>&1
|
patch -d $_builddir -p1 < ${_srcdir}/${_patch_file} > $tmp_err_msg 2>&1
|
||||||
if [[ $? -eq 0 ]]; then
|
if [[ $? -eq 0 ]]; then
|
||||||
@@ -6399,38 +6421,111 @@ else
|
|||||||
echo_skipped
|
echo_skipped
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# - Security patches for PHP 8.1.34 (source: omega8cc/boa, aegir/patches/php-sec)
|
# - Security patches for PHP 5.6.40, 7.4.33, 8.0.30 and 8.1.34
|
||||||
|
# - (source: omega8cc/boa, aegir/patches/php-sec)
|
||||||
# -
|
# -
|
||||||
|
# - PHP 5.6.40 (boa order = glob order, applied with --fuzz=0 by boa):
|
||||||
|
# - php-5.6.40-openssl3-pkey-export.patch
|
||||||
|
# - php-5.6.40-round-places-overflow.patch
|
||||||
|
# - php-5.6.40-sury-105.patch (backports, Debian/sury; contains
|
||||||
|
# - the CVE-2026-109618/109619 fix)
|
||||||
|
# - php-5.6.40-xlts-1.patch
|
||||||
|
# - php-5.6.40-xlts-2.patch (needs sury-105 and xlts-1)
|
||||||
|
# - On top of 'PHP-5.6.31-OpenSSL-1.1.0-compatibility-20170801.patch' and
|
||||||
|
# - the php-5.6-*.patch files above all apply without fuzz (offsets only).
|
||||||
|
# - They change no generated files (Zend VM, re2c).
|
||||||
|
# -
|
||||||
|
# - PHP 7.4.33:
|
||||||
|
# - php-7.4.33-cve-2026-109618-109619.patch
|
||||||
|
# - php-7.4.33-sury-31.patch (backports from 8.x, Debian/sury)
|
||||||
|
# - php-7.4.33-xlts-1.patch (mysqlnd)
|
||||||
|
# - php-7.4.33-xlts-2.patch
|
||||||
|
# - php-7.4.33-sury-31-re2c-generated.patch
|
||||||
|
# - (own patch: the *.re hunks of sury-31 for pdo_sql_parser and
|
||||||
|
# - url_scanner_ex applied to the generated *.c files, so the fixes
|
||||||
|
# - are built without re2c)
|
||||||
|
# -
|
||||||
|
# - PHP 8.0.30:
|
||||||
|
# - php-8.0.30-cve-2026-109618-109619.patch
|
||||||
|
# - php-8.0.30-sury-25.patch (backports from 8.x, Debian/sury)
|
||||||
|
# - php-8.0.30-xlts-1.patch (mysqlnd)
|
||||||
|
# - php-8.0.30-xlts-2.patch
|
||||||
|
# - php-8.0.30-sury-25-re2c-generated.patch
|
||||||
|
# - (own patch: the *.re hunks of sury-25 for pdo_sql_parser and
|
||||||
|
# - url_scanner_ex applied to the generated *.c files, so the fixes
|
||||||
|
# - are built without re2c)
|
||||||
|
# -
|
||||||
|
# - PHP 8.1.34:
|
||||||
# - php-8.1.34-cve-2026-109618-109619.patch
|
# - php-8.1.34-cve-2026-109618-109619.patch
|
||||||
# - php-8.1.34-sury-9.patch (backports from 8.2.x, Debian/sury)
|
# - php-8.1.34-sury-9.patch (backports from 8.2.x, Debian/sury)
|
||||||
# - php-8.1.34-cve-2026-129291.patch (php-fpm)
|
# - php-8.1.34-cve-2026-129291.patch (php-fpm)
|
||||||
|
# - php-8.1.34-xlts-2.patch
|
||||||
# - php-8.1.34-sury-9-re2c-generated.patch
|
# - php-8.1.34-sury-9-re2c-generated.patch
|
||||||
# - (own patch: the *.re hunks of sury-9 for pdo_sql_parser and
|
# - (own patch: the *.re hunks of sury-9 for pdo_sql_parser and
|
||||||
# - url_scanner_ex applied to the generated *.c files, so the fixes
|
# - url_scanner_ex applied to the generated *.c files, so the fixes
|
||||||
# - are built without re2c)
|
# - are built without re2c)
|
||||||
# -
|
# -
|
||||||
# - Order matters: the CVE-2026-109618/109619 patch MUST be applied before
|
# - Order matters: the CVE-2026-109618/109619 patch MUST be applied before
|
||||||
# - 'php-8.1.34-sury-9.patch', otherwise hunk #4 of main/rfc1867.c fails.
|
# - the sury patch, otherwise hunk #4 of main/rfc1867.c fails. In the order
|
||||||
# - In the order below all three apply cleanly (no fuzz) to php-8.1.34.
|
# - below all patches apply cleanly (no fuzz) - for 7.4.33 and 8.0.30 also
|
||||||
|
# - on top of 'PHP-7.4-OpenSSL-3.0-compatibility.patch' and
|
||||||
|
# - 'PHP-8.0-OpenSSL-3.0-compatibility.patch'.
|
||||||
# -
|
# -
|
||||||
# - The patches are applied to the unpacked tree '${_srcdir}/php-${VERSION}'
|
# - The patches are applied to the unpacked tree '${_srcdir}/php-${VERSION}'
|
||||||
# - (not $_builddir), because with apache mod_php the tree is moved to
|
# - (not $_builddir), because with apache mod_php the tree is moved to
|
||||||
# - $_builddir only further below.
|
# - $_builddir only further below.
|
||||||
# -
|
# -
|
||||||
# - Security fixes: if one fails, abort - never build PHP 8.1.34 without them.
|
# - Security fixes: if one fails, abort - never build PHP without them.
|
||||||
# -
|
# -
|
||||||
if [[ "$VERSION" = "8.1.34" ]]; then
|
case "$VERSION" in
|
||||||
for _patch_file in \
|
5.6.40)
|
||||||
php-8.1.34-cve-2026-109618-109619.patch \
|
_sec_patches="
|
||||||
php-8.1.34-sury-9.patch \
|
php-5.6.40-openssl3-pkey-export.patch
|
||||||
php-8.1.34-cve-2026-129291.patch \
|
php-5.6.40-round-places-overflow.patch
|
||||||
php-8.1.34-sury-9-re2c-generated.patch ; do
|
php-5.6.40-sury-105.patch
|
||||||
|
php-5.6.40-xlts-1.patch
|
||||||
|
php-5.6.40-xlts-2.patch"
|
||||||
|
;;
|
||||||
|
7.4.33)
|
||||||
|
_sec_patches="
|
||||||
|
php-7.4.33-cve-2026-109618-109619.patch
|
||||||
|
php-7.4.33-sury-31.patch
|
||||||
|
php-7.4.33-xlts-1.patch
|
||||||
|
php-7.4.33-xlts-2.patch
|
||||||
|
php-7.4.33-sury-31-re2c-generated.patch"
|
||||||
|
;;
|
||||||
|
8.0.30)
|
||||||
|
_sec_patches="
|
||||||
|
php-8.0.30-cve-2026-109618-109619.patch
|
||||||
|
php-8.0.30-sury-25.patch
|
||||||
|
php-8.0.30-xlts-1.patch
|
||||||
|
php-8.0.30-xlts-2.patch
|
||||||
|
php-8.0.30-sury-25-re2c-generated.patch"
|
||||||
|
;;
|
||||||
|
8.1.34)
|
||||||
|
_sec_patches="
|
||||||
|
php-8.1.34-cve-2026-109618-109619.patch
|
||||||
|
php-8.1.34-sury-9.patch
|
||||||
|
php-8.1.34-cve-2026-129291.patch
|
||||||
|
php-8.1.34-xlts-2.patch
|
||||||
|
php-8.1.34-sury-9-re2c-generated.patch"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
_sec_patches=""
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [[ -n "$_sec_patches" ]]; then
|
||||||
|
for _patch_file in $_sec_patches ; do
|
||||||
echononl "\tApply ${_patch_file}"
|
echononl "\tApply ${_patch_file}"
|
||||||
if [[ ! -f "${_srcdir}/${_patch_file}" ]] ; then
|
if [[ ! -f "${_srcdir}/${_patch_file}" ]] ; then
|
||||||
echo_failed
|
echo_failed
|
||||||
fatal "Can't find patchfile '${_srcdir}/${_patch_file}'"
|
fatal "Can't find patchfile '${_srcdir}/${_patch_file}'"
|
||||||
fi
|
fi
|
||||||
if grep -qi '<html' "${_srcdir}/${_patch_file}" ; then
|
# - Only look at the first non-empty line: a patch may contain '<html'
|
||||||
|
# - in test files (e.g. php-8.0.30-sury-25.patch).
|
||||||
|
# -
|
||||||
|
if grep -m1 -v '^[[:space:]]*$' "${_srcdir}/${_patch_file}" | grep -qiE '^[[:space:]]*<(!doctype html|html)' ; then
|
||||||
echo_failed
|
echo_failed
|
||||||
fatal "'${_srcdir}/${_patch_file}' is an HTML page, not a patch!\n\t (Download the 'raw' file, not the GitHub page)"
|
fatal "'${_srcdir}/${_patch_file}' is an HTML page, not a patch!\n\t (Download the 'raw' file, not the GitHub page)"
|
||||||
fi
|
fi
|
||||||
@@ -6472,7 +6567,7 @@ if [[ "$VERSION" = "8.1.34" ]]; then
|
|||||||
fatal "$(cat $tmp_err_msg)"
|
fatal "$(cat $tmp_err_msg)"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echononl "\tApply PHP 8.1.34 security patches"
|
echononl "\tApply PHP security patches (omega8cc/boa)"
|
||||||
echo_skipped
|
echo_skipped
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -6913,25 +7008,68 @@ if [[ "${FPM_RUN_DIR}" =~ ^/run/ ]] ; then
|
|||||||
echo "" >> ${_logdir}/main.log
|
echo "" >> ${_logdir}/main.log
|
||||||
echo "## - Force systemd to create run directory on each startup." >> ${_logdir}/main.log
|
echo "## - Force systemd to create run directory on each startup." >> ${_logdir}/main.log
|
||||||
echo "## -" >> ${_logdir}/main.log
|
echo "## -" >> ${_logdir}/main.log
|
||||||
echo "## - Create '/etc/tmpfiles.d/mysql.conf' with content:" >> ${_logdir}/main.log
|
echo "## - Create '/etc/tmpfiles.d/php-fpm.conf' with content:" >> ${_logdir}/main.log
|
||||||
echo "## -" >> ${_logdir}/main.log
|
echo "## -" >> ${_logdir}/main.log
|
||||||
echo "## - # systemd tmpfile settings for mysql or mariadb" >> ${_logdir}/main.log
|
echo "## - # systemd tmpfile settings for php fpm" >> ${_logdir}/main.log
|
||||||
echo "## - d $FPM_RUN_DIR 0755 $FPM_DEFAULT_POOL_USER $FPM_DEFAULT_POOL_GROUP -" >> ${_logdir}/main.log
|
echo "## - d $FPM_RUN_DIR 0755 $FPM_DEFAULT_POOL_USER $FPM_DEFAULT_POOL_GROUP -" >> ${_logdir}/main.log
|
||||||
echo "## -" >> ${_logdir}/main.log
|
echo "## -" >> ${_logdir}/main.log
|
||||||
echo "" >> ${_logdir}/main.log
|
echo "" >> ${_logdir}/main.log
|
||||||
echo "cat << EOF > /etc/tmpfiles.d/php-fpm.conf
|
|
||||||
# systemd tmpfile settings for php fpm
|
## - /etc/tmpfiles.d/php-fpm.conf is shared by all installed PHP versions.
|
||||||
d $FPM_RUN_DIR 0755 $FPM_DEFAULT_POOL_USER $FPM_DEFAULT_POOL_GROUP -
|
## - A broken entry (e.g. unknown user/group) makes systemd-tmpfiles skip
|
||||||
EOF" >> ${_logdir}/main.log
|
## - the line at boot, so /run/php is missing and no php-fpm starts.
|
||||||
cat <<EOF > /etc/tmpfiles.d/php-fpm.conf
|
## - Therefore: verify user/group, validate the new file with
|
||||||
|
## - systemd-tmpfiles and only then replace the existing one.
|
||||||
|
## -
|
||||||
|
_tmpfiles_conf="/etc/tmpfiles.d/php-fpm.conf"
|
||||||
|
_tmpfiles_ok=true
|
||||||
|
_tmpfiles_msg=""
|
||||||
|
|
||||||
|
if ! getent passwd "$FPM_DEFAULT_POOL_USER" > /dev/null 2>&1 ; then
|
||||||
|
_tmpfiles_ok=false
|
||||||
|
_tmpfiles_msg="User '$FPM_DEFAULT_POOL_USER' does not exist."
|
||||||
|
elif ! getent group "$FPM_DEFAULT_POOL_GROUP" > /dev/null 2>&1 ; then
|
||||||
|
_tmpfiles_ok=false
|
||||||
|
_tmpfiles_msg="Group '$FPM_DEFAULT_POOL_GROUP' does not exist."
|
||||||
|
fi
|
||||||
|
|
||||||
|
if $_tmpfiles_ok ; then
|
||||||
|
_tmpfiles_new="$(mktemp /tmp/php-fpm-tmpfiles.XXXXXX.conf)"
|
||||||
|
cat <<EOF > "$_tmpfiles_new"
|
||||||
# systemd tmpfile settings for php fpm
|
# systemd tmpfile settings for php fpm
|
||||||
d $FPM_RUN_DIR 0755 $FPM_DEFAULT_POOL_USER $FPM_DEFAULT_POOL_GROUP -
|
d $FPM_RUN_DIR 0755 $FPM_DEFAULT_POOL_USER $FPM_DEFAULT_POOL_GROUP -
|
||||||
EOF
|
EOF
|
||||||
if [[ $? -eq 0 ]] ; then
|
echo "cat << EOF > $_tmpfiles_conf" >> ${_logdir}/main.log
|
||||||
|
cat "$_tmpfiles_new" >> ${_logdir}/main.log
|
||||||
|
echo "EOF" >> ${_logdir}/main.log
|
||||||
|
|
||||||
|
if command -v systemd-tmpfiles > /dev/null 2>&1 ; then
|
||||||
|
echo "" >> ${_logdir}/main.log
|
||||||
|
echo "systemd-tmpfiles --create $_tmpfiles_new" >> ${_logdir}/main.log
|
||||||
|
_tmpfiles_out="$(systemd-tmpfiles --create "$_tmpfiles_new" 2>&1)"
|
||||||
|
_tmpfiles_rc=$?
|
||||||
|
[[ -n "$_tmpfiles_out" ]] && echo "$_tmpfiles_out" >> ${_logdir}/main.log
|
||||||
|
if [[ $_tmpfiles_rc -ne 0 ]] || [[ -n "$_tmpfiles_out" ]] ; then
|
||||||
|
_tmpfiles_ok=false
|
||||||
|
_tmpfiles_msg="systemd-tmpfiles rejected the new configuration: $_tmpfiles_out"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if $_tmpfiles_ok ; then
|
||||||
|
install -m 0644 -o root -g root "$_tmpfiles_new" "$_tmpfiles_conf" >> ${_logdir}/main.log 2>&1 || {
|
||||||
|
_tmpfiles_ok=false
|
||||||
|
_tmpfiles_msg="Installing '$_tmpfiles_conf' failed."
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
rm -f "$_tmpfiles_new"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if $_tmpfiles_ok ; then
|
||||||
echo_ok
|
echo_ok
|
||||||
else
|
else
|
||||||
echo_failed
|
echo_failed
|
||||||
error "Creating file '/etc/tmpfiles.d/php-fpm.conf' failed!"
|
echo "## - ERROR: $_tmpfiles_msg ('$_tmpfiles_conf' left unchanged)" >> ${_logdir}/main.log
|
||||||
|
error "Creating file '$_tmpfiles_conf' failed!\n\t $_tmpfiles_msg\n\t '$_tmpfiles_conf' was left unchanged - check it before rebooting!"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c
|
||||||
|
index af376aa..5116a4a 100644
|
||||||
|
--- a/ext/openssl/openssl.c
|
||||||
|
+++ b/ext/openssl/openssl.c
|
||||||
|
@@ -4001,6 +4001,9 @@ PHP_FUNCTION(openssl_pkey_export_to_file)
|
||||||
|
|
||||||
|
if (PHP_SSL_REQ_PARSE(&req, args) == SUCCESS) {
|
||||||
|
bio_out = BIO_new_file(filename, "w");
|
||||||
|
+ if (bio_out == NULL) {
|
||||||
|
+ goto clean_exit;
|
||||||
|
+ }
|
||||||
|
|
||||||
|
if (passphrase && req.priv_key_encrypt) {
|
||||||
|
if (req.priv_key_encrypt_cipher) {
|
||||||
|
@@ -4029,6 +4032,7 @@ PHP_FUNCTION(openssl_pkey_export_to_file)
|
||||||
|
RETVAL_TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
+clean_exit:
|
||||||
|
PHP_SSL_REQ_DISPOSE(&req);
|
||||||
|
|
||||||
|
if (key_resource == -1 && key) {
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
--- a/ext/standard/math.c
|
||||||
|
+++ b/ext/standard/math.c
|
||||||
|
@@ -141,7 +141,7 @@
|
||||||
|
double tmp_value;
|
||||||
|
int precision_places;
|
||||||
|
|
||||||
|
- if (!php_math_is_finite(value)) {
|
||||||
|
+ if (!php_math_is_finite(value) || value == 0.0) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -153,7 +153,7 @@
|
||||||
|
/* If the decimal precision guaranteed by FP arithmetic is higher than
|
||||||
|
the requested places BUT is small enough to make sure a non-zero value
|
||||||
|
is returned, pre-round the result to the precision */
|
||||||
|
- if (precision_places > places && precision_places - places < 15) {
|
||||||
|
+ if (precision_places > places && precision_places - 15 < places) {
|
||||||
|
int64_t use_precision = precision_places < INT_MIN+1 ? INT_MIN+1 : precision_places;
|
||||||
|
|
||||||
|
f2 = php_intpow10(abs((int)use_precision));
|
||||||
+221268
File diff suppressed because it is too large.
Load diff
+10434
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,942 @@
|
|||||||
|
diff --git a/Zend/zend_API.h b/Zend/zend_API.h
|
||||||
|
index 2a3b582902..26f7726bd8 100644
|
||||||
|
--- a/Zend/zend_API.h
|
||||||
|
+++ b/Zend/zend_API.h
|
||||||
|
@@ -380,6 +380,7 @@ ZEND_API char *zend_get_type_by_const(int type);
|
||||||
|
|
||||||
|
#define array_init(arg) ZVAL_ARR((arg), zend_new_array(0))
|
||||||
|
#define array_init_size(arg, size) ZVAL_ARR((arg), zend_new_array(size))
|
||||||
|
+#define array_init_singleton(arg) ZVAL_ARR((arg), zend_new_array_singleton())
|
||||||
|
ZEND_API int object_init(zval *arg);
|
||||||
|
ZEND_API int object_init_ex(zval *arg, zend_class_entry *ce);
|
||||||
|
ZEND_API int object_and_properties_init(zval *arg, zend_class_entry *ce, HashTable *properties);
|
||||||
|
diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c
|
||||||
|
index 3a33e5441c..be9b975426 100644
|
||||||
|
--- a/Zend/zend_alloc.c
|
||||||
|
+++ b/Zend/zend_alloc.c
|
||||||
|
@@ -57,6 +57,7 @@
|
||||||
|
#include "zend_operators.h"
|
||||||
|
#include "zend_multiply.h"
|
||||||
|
#include "zend_bitset.h"
|
||||||
|
+#include "zend_execute.h"
|
||||||
|
#include <signal.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_UNISTD_H
|
||||||
|
@@ -363,7 +364,42 @@ static ZEND_COLD ZEND_NORETURN void zend_mm_panic(const char *message)
|
||||||
|
#if ZEND_DEBUG && defined(HAVE_KILL) && defined(HAVE_GETPID)
|
||||||
|
kill(getpid(), SIGSEGV);
|
||||||
|
#endif
|
||||||
|
- exit(1);
|
||||||
|
+ _exit(1);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+ZEND_API ZEND_COLD ZEND_NORETURN void zend_mm_safe_error_ex(const char *format, ...)
|
||||||
|
+{
|
||||||
|
+ zend_string *script_filename = NULL;
|
||||||
|
+ uint32_t script_lineno = 0;
|
||||||
|
+
|
||||||
|
+ if (zend_is_executing()) {
|
||||||
|
+ script_filename = zend_get_executed_filename_ex();
|
||||||
|
+ script_lineno = zend_get_executed_lineno();
|
||||||
|
+ } else if (zend_is_compiling()) {
|
||||||
|
+ script_filename = zend_get_compiled_filename();
|
||||||
|
+ script_lineno = zend_get_compiled_lineno();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ va_list args;
|
||||||
|
+ va_start(args, format);
|
||||||
|
+
|
||||||
|
+ char buf[1024];
|
||||||
|
+ vsnprintf(buf, sizeof(buf), format, args);
|
||||||
|
+
|
||||||
|
+ va_end(args);
|
||||||
|
+
|
||||||
|
+ fprintf(stderr,
|
||||||
|
+ "\nFatal error: %s in %s on line %d\n",
|
||||||
|
+ buf,
|
||||||
|
+ script_filename ? ZSTR_VAL(script_filename) : "Unknown",
|
||||||
|
+ script_lineno);
|
||||||
|
+
|
||||||
|
+ /* See http://support.microsoft.com/kb/190351 */
|
||||||
|
+# ifdef ZEND_WIN32
|
||||||
|
+ fflush(stderr);
|
||||||
|
+# endif
|
||||||
|
+
|
||||||
|
+ _exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static ZEND_COLD ZEND_NORETURN void zend_mm_safe_error(zend_mm_heap *heap,
|
||||||
|
@@ -375,22 +411,14 @@ static ZEND_COLD ZEND_NORETURN void zend_mm_safe_error(zend_mm_heap *heap,
|
||||||
|
#endif
|
||||||
|
size_t size)
|
||||||
|
{
|
||||||
|
+ (void) heap;
|
||||||
|
|
||||||
|
- heap->overflow = 1;
|
||||||
|
- zend_try {
|
||||||
|
- zend_error_noreturn(E_ERROR,
|
||||||
|
- format,
|
||||||
|
- limit,
|
||||||
|
+ zend_mm_safe_error_ex(format, limit,
|
||||||
|
#if ZEND_DEBUG
|
||||||
|
- filename,
|
||||||
|
- lineno,
|
||||||
|
+ filename,
|
||||||
|
+ lineno,
|
||||||
|
#endif
|
||||||
|
- size);
|
||||||
|
- } zend_catch {
|
||||||
|
- } zend_end_try();
|
||||||
|
- heap->overflow = 0;
|
||||||
|
- zend_bailout();
|
||||||
|
- exit(1);
|
||||||
|
+ size);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
@@ -1318,7 +1346,7 @@ static zend_always_inline void *zend_mm_alloc_heap(zend_mm_heap *heap, size_t si
|
||||||
|
size = MAX(size, 1);
|
||||||
|
size = ZEND_MM_ALIGNED_SIZE(size) + ZEND_MM_ALIGNED_SIZE(sizeof(zend_mm_debug_info));
|
||||||
|
if (UNEXPECTED(size < real_size)) {
|
||||||
|
- zend_error_noreturn(E_ERROR, "Possible integer overflow in memory allocation (%zu + %zu)", ZEND_MM_ALIGNED_SIZE(real_size), ZEND_MM_ALIGNED_SIZE(sizeof(zend_mm_debug_info)));
|
||||||
|
+ zend_mm_safe_error_ex("Possible integer overflow in memory allocation (%zu + %zu)", ZEND_MM_ALIGNED_SIZE(real_size), ZEND_MM_ALIGNED_SIZE(sizeof(zend_mm_debug_info)));
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
@@ -1762,7 +1790,7 @@ static void *zend_mm_alloc_huge(zend_mm_heap *heap, size_t size ZEND_FILE_LINE_D
|
||||||
|
void *ptr;
|
||||||
|
|
||||||
|
if (UNEXPECTED(new_size < size)) {
|
||||||
|
- zend_error_noreturn(E_ERROR, "Possible integer overflow in memory allocation (%zu + %zu)", size, alignment);
|
||||||
|
+ zend_mm_safe_error_ex("Possible integer overflow in memory allocation (%zu + %zu)", size, alignment);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if ZEND_MM_LIMIT
|
||||||
|
@@ -2617,7 +2645,7 @@ ZEND_API char* ZEND_FASTCALL _estrdup(const char *s ZEND_FILE_LINE_DC ZEND_FILE_
|
||||||
|
|
||||||
|
length = strlen(s);
|
||||||
|
if (UNEXPECTED(length + 1 == 0)) {
|
||||||
|
- zend_error_noreturn(E_ERROR, "Possible integer overflow in memory allocation (1 * %zu + 1)", length);
|
||||||
|
+ zend_mm_safe_error_ex("Possible integer overflow in memory allocation (1 * %zu + 1)", length);
|
||||||
|
}
|
||||||
|
p = (char *) _emalloc(length + 1 ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
|
||||||
|
memcpy(p, s, length+1);
|
||||||
|
@@ -2629,7 +2657,7 @@ ZEND_API char* ZEND_FASTCALL _estrndup(const char *s, size_t length ZEND_FILE_LI
|
||||||
|
char *p;
|
||||||
|
|
||||||
|
if (UNEXPECTED(length + 1 == 0)) {
|
||||||
|
- zend_error_noreturn(E_ERROR, "Possible integer overflow in memory allocation (1 * %zu + 1)", length);
|
||||||
|
+ zend_mm_safe_error_ex("Possible integer overflow in memory allocation (1 * %zu + 1)", length);
|
||||||
|
}
|
||||||
|
p = (char *) _emalloc(length + 1 ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
|
||||||
|
memcpy(p, s, length);
|
||||||
|
@@ -2643,7 +2671,7 @@ ZEND_API char* ZEND_FASTCALL zend_strndup(const char *s, size_t length)
|
||||||
|
char *p;
|
||||||
|
|
||||||
|
if (UNEXPECTED(length + 1 == 0)) {
|
||||||
|
- zend_error_noreturn(E_ERROR, "Possible integer overflow in memory allocation (1 * %zu + 1)", length);
|
||||||
|
+ zend_mm_safe_error_ex("Possible integer overflow in memory allocation (1 * %zu + 1)", length);
|
||||||
|
}
|
||||||
|
p = (char *) malloc(length + 1);
|
||||||
|
if (UNEXPECTED(p == NULL)) {
|
||||||
|
@@ -2974,7 +3002,7 @@ ZEND_API zend_mm_heap *zend_mm_startup_ex(const zend_mm_handlers *handlers, void
|
||||||
|
static ZEND_COLD ZEND_NORETURN void zend_out_of_memory(void)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Out of memory\n");
|
||||||
|
- exit(1);
|
||||||
|
+ _exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
ZEND_API void * __zend_malloc(size_t len)
|
||||||
|
diff --git a/Zend/zend_alloc.h b/Zend/zend_alloc.h
|
||||||
|
index 8bb854328d..2ed2ed8b3a 100644
|
||||||
|
--- a/Zend/zend_alloc.h
|
||||||
|
+++ b/Zend/zend_alloc.h
|
||||||
|
@@ -402,6 +402,8 @@ static void apc_init_heap(void)
|
||||||
|
size_t zend_mm_globals_size(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
+ZEND_API ZEND_COLD ZEND_NORETURN void zend_mm_safe_error_ex(const char *format, ...);
|
||||||
|
+
|
||||||
|
END_EXTERN_C()
|
||||||
|
|
||||||
|
#endif
|
||||||
|
diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c
|
||||||
|
index f4f0fa14f1..724b6e5cc4 100644
|
||||||
|
--- a/Zend/zend_execute_API.c
|
||||||
|
+++ b/Zend/zend_execute_API.c
|
||||||
|
@@ -337,10 +337,21 @@ void shutdown_executor(void) /* {{{ */
|
||||||
|
gc_collect_cycles();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
+ } else {
|
||||||
|
+ /* may be used by zend_error_zstr_at before init_executor */
|
||||||
|
+ ZVAL_UNDEF(&EG(user_error_handler));
|
||||||
|
+ ZVAL_UNDEF(&EG(user_exception_handler));
|
||||||
|
+ memset(&EG(user_error_handlers_error_reporting), 0, sizeof(EG(user_error_handlers_error_reporting)));
|
||||||
|
+ memset(&EG(user_error_handlers), 0, sizeof(EG(user_error_handlers)));
|
||||||
|
+ memset(&EG(user_exception_handlers), 0, sizeof(EG(user_exception_handlers)));
|
||||||
|
}
|
||||||
|
|
||||||
|
zend_objects_store_free_object_storage(&EG(objects_store), fast_shutdown);
|
||||||
|
|
||||||
|
+ /* may be used by zend_error_zstr_at before init_executor */
|
||||||
|
+ EG(error_handling) = EH_NORMAL;
|
||||||
|
+ EG(exception) = NULL;
|
||||||
|
+
|
||||||
|
zend_weakrefs_shutdown();
|
||||||
|
|
||||||
|
zend_try {
|
||||||
|
@@ -357,6 +368,8 @@ void shutdown_executor(void) /* {{{ */
|
||||||
|
zend_hash_discard(EG(function_table), EG(persistent_functions_count));
|
||||||
|
zend_hash_discard(EG(class_table), EG(persistent_classes_count));
|
||||||
|
zend_cleanup_internal_classes();
|
||||||
|
+ EG(objects_store).object_buckets = NULL;
|
||||||
|
+ EG(objects_store).top = 1;
|
||||||
|
} else {
|
||||||
|
zend_vm_stack_destroy();
|
||||||
|
|
||||||
|
diff --git a/Zend/zend_hash.c b/Zend/zend_hash.c
|
||||||
|
index da150bd798..ef3d301db1 100644
|
||||||
|
--- a/Zend/zend_hash.c
|
||||||
|
+++ b/Zend/zend_hash.c
|
||||||
|
@@ -97,7 +97,7 @@ static zend_always_inline uint32_t zend_hash_check_size(uint32_t nSize)
|
||||||
|
if (nSize <= HT_MIN_SIZE) {
|
||||||
|
return HT_MIN_SIZE;
|
||||||
|
} else if (UNEXPECTED(nSize >= HT_MAX_SIZE)) {
|
||||||
|
- zend_error_noreturn(E_ERROR, "Possible integer overflow in memory allocation (%u * %zu + %zu)", nSize, sizeof(Bucket), sizeof(Bucket));
|
||||||
|
+ zend_mm_safe_error_ex("Possible integer overflow in memory allocation (%u * %zu + %zu)", nSize, sizeof(Bucket), sizeof(Bucket));
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(ZEND_WIN32)
|
||||||
|
@@ -251,6 +251,13 @@ ZEND_API HashTable* ZEND_FASTCALL _zend_new_array_0(void)
|
||||||
|
return ht;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ZEND_API HashTable* ZEND_FASTCALL zend_new_array_singleton(void)
|
||||||
|
+{
|
||||||
|
+ HashTable *ht = _zend_new_array_0();
|
||||||
|
+ ht->nTableSize = 1;
|
||||||
|
+ return ht;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
ZEND_API HashTable* ZEND_FASTCALL _zend_new_array(uint32_t nSize)
|
||||||
|
{
|
||||||
|
HashTable *ht = emalloc(sizeof(HashTable));
|
||||||
|
@@ -282,7 +289,7 @@ static void ZEND_FASTCALL zend_hash_packed_grow(HashTable *ht)
|
||||||
|
{
|
||||||
|
HT_ASSERT_RC1(ht);
|
||||||
|
if (ht->nTableSize >= HT_MAX_SIZE) {
|
||||||
|
- zend_error_noreturn(E_ERROR, "Possible integer overflow in memory allocation (%u * %zu + %zu)", ht->nTableSize * 2, sizeof(Bucket), sizeof(Bucket));
|
||||||
|
+ zend_mm_safe_error_ex("Possible integer overflow in memory allocation (%u * %zu + %zu)", ht->nTableSize * 2, sizeof(Bucket), sizeof(Bucket));
|
||||||
|
}
|
||||||
|
ht->nTableSize += ht->nTableSize;
|
||||||
|
HT_SET_DATA_ADDR(ht, perealloc2(HT_GET_DATA_ADDR(ht), HT_SIZE_EX(ht->nTableSize, HT_MIN_MASK), HT_USED_SIZE(ht), GC_FLAGS(ht) & IS_ARRAY_PERSISTENT));
|
||||||
|
@@ -1164,7 +1171,7 @@ static void ZEND_FASTCALL zend_hash_do_resize(HashTable *ht)
|
||||||
|
pefree(old_data, GC_FLAGS(ht) & IS_ARRAY_PERSISTENT);
|
||||||
|
zend_hash_rehash(ht);
|
||||||
|
} else {
|
||||||
|
- zend_error_noreturn(E_ERROR, "Possible integer overflow in memory allocation (%u * %zu + %zu)", ht->nTableSize * 2, sizeof(Bucket) + sizeof(uint32_t), sizeof(Bucket));
|
||||||
|
+ zend_mm_safe_error_ex("Possible integer overflow in memory allocation (%u * %zu + %zu)", ht->nTableSize * 2, sizeof(Bucket) + sizeof(uint32_t), sizeof(Bucket));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/Zend/zend_hash.h b/Zend/zend_hash.h
|
||||||
|
index f1e2d34685..b833479eaa 100644
|
||||||
|
--- a/Zend/zend_hash.h
|
||||||
|
+++ b/Zend/zend_hash.h
|
||||||
|
@@ -296,6 +296,7 @@ ZEND_API int ZEND_FASTCALL zend_hash_rehash(HashTable *ht);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ZEND_API HashTable* ZEND_FASTCALL _zend_new_array_0(void);
|
||||||
|
+ZEND_API HashTable* ZEND_FASTCALL zend_new_array_singleton(void);
|
||||||
|
ZEND_API HashTable* ZEND_FASTCALL _zend_new_array(uint32_t size);
|
||||||
|
ZEND_API HashTable* ZEND_FASTCALL zend_new_pair(zval *val1, zval *val2);
|
||||||
|
ZEND_API uint32_t zend_array_count(HashTable *ht);
|
||||||
|
diff --git a/Zend/zend_llist.c b/Zend/zend_llist.c
|
||||||
|
index 4a2c22e632..0955e953aa 100644
|
||||||
|
--- a/Zend/zend_llist.c
|
||||||
|
+++ b/Zend/zend_llist.c
|
||||||
|
@@ -112,6 +112,8 @@ ZEND_API void zend_llist_destroy(zend_llist *l)
|
||||||
|
current = next;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ l->head = NULL;
|
||||||
|
+ l->tail = NULL;
|
||||||
|
l->count = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/Zend/zend_multiply.h b/Zend/zend_multiply.h
|
||||||
|
index a3827d25d1..a9bbda5538 100644
|
||||||
|
--- a/Zend/zend_multiply.h
|
||||||
|
+++ b/Zend/zend_multiply.h
|
||||||
|
@@ -321,7 +321,7 @@ static zend_always_inline size_t zend_safe_address_guarded(size_t nmemb, size_t
|
||||||
|
size_t ret = zend_safe_address(nmemb, size, offset, &overflow);
|
||||||
|
|
||||||
|
if (UNEXPECTED(overflow)) {
|
||||||
|
- zend_error_noreturn(E_ERROR, "Possible integer overflow in memory allocation (%zu * %zu + %zu)", nmemb, size, offset);
|
||||||
|
+ zend_mm_safe_error_ex("Possible integer overflow in memory allocation (%zu * %zu + %zu)", nmemb, size, offset);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
@@ -334,7 +334,7 @@ static zend_always_inline size_t zend_safe_addmult(size_t nmemb, size_t size, si
|
||||||
|
size_t ret = zend_safe_address(nmemb, size, offset, &overflow);
|
||||||
|
|
||||||
|
if (UNEXPECTED(overflow)) {
|
||||||
|
- zend_error_noreturn(E_ERROR, "Possible integer overflow in %s (%zu * %zu + %zu)", message, nmemb, size, offset);
|
||||||
|
+ zend_mm_safe_error_ex("Possible integer overflow in %s (%zu * %zu + %zu)", message, nmemb, size, offset);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
diff --git a/Zend/zend_strtod.c b/Zend/zend_strtod.c
|
||||||
|
index 2228e2262c..ad8df201af 100644
|
||||||
|
--- a/Zend/zend_strtod.c
|
||||||
|
+++ b/Zend/zend_strtod.c
|
||||||
|
@@ -603,7 +603,7 @@ Balloc
|
||||||
|
rv = (Bigint *)MALLOC(sizeof(Bigint) + (x-1)*sizeof(ULong));
|
||||||
|
if (!rv) {
|
||||||
|
FREE_DTOA_LOCK(0);
|
||||||
|
- zend_error_noreturn(E_ERROR, "Balloc() failed to allocate memory");
|
||||||
|
+ zend_mm_safe_error_ex("Balloc() failed to allocate memory");
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
len = (sizeof(Bigint) + (x-1)*sizeof(ULong) + sizeof(double) - 1)
|
||||||
|
@@ -616,7 +616,7 @@ Balloc
|
||||||
|
rv = (Bigint*)MALLOC(len*sizeof(double));
|
||||||
|
if (!rv) {
|
||||||
|
FREE_DTOA_LOCK(0);
|
||||||
|
- zend_error_noreturn(E_ERROR, "Balloc() failed to allocate memory");
|
||||||
|
+ zend_mm_safe_error_ex("Balloc() failed to allocate memory");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
rv->k = k;
|
||||||
|
diff --git a/Zend/zend_types.h b/Zend/zend_types.h
|
||||||
|
index 7b8c079c45..f7828eb6d3 100644
|
||||||
|
--- a/Zend/zend_types.h
|
||||||
|
+++ b/Zend/zend_types.h
|
||||||
|
@@ -330,17 +330,21 @@ struct _zend_array {
|
||||||
|
# define HT_HASH_RESET(ht) do { \
|
||||||
|
char *p = (char*)&HT_HASH(ht, (ht)->nTableMask); \
|
||||||
|
size_t size = HT_HASH_SIZE((ht)->nTableMask); \
|
||||||
|
- __m128i xmm0 = _mm_setzero_si128(); \
|
||||||
|
- xmm0 = _mm_cmpeq_epi8(xmm0, xmm0); \
|
||||||
|
- ZEND_ASSERT(size >= 64 && ((size & 0x3f) == 0)); \
|
||||||
|
- do { \
|
||||||
|
- _mm_storeu_si128((__m128i*)p, xmm0); \
|
||||||
|
- _mm_storeu_si128((__m128i*)(p+16), xmm0); \
|
||||||
|
- _mm_storeu_si128((__m128i*)(p+32), xmm0); \
|
||||||
|
- _mm_storeu_si128((__m128i*)(p+48), xmm0); \
|
||||||
|
- p += 64; \
|
||||||
|
- size -= 64; \
|
||||||
|
- } while (size != 0); \
|
||||||
|
+ if (UNEXPECTED(size < 64)) { \
|
||||||
|
+ memset(p, HT_INVALID_IDX, size); \
|
||||||
|
+ } else { \
|
||||||
|
+ __m128i xmm0 = _mm_setzero_si128(); \
|
||||||
|
+ xmm0 = _mm_cmpeq_epi8(xmm0, xmm0); \
|
||||||
|
+ ZEND_ASSERT(size >= 64 && ((size & 0x3f) == 0)); \
|
||||||
|
+ do { \
|
||||||
|
+ _mm_storeu_si128((__m128i*)p, xmm0); \
|
||||||
|
+ _mm_storeu_si128((__m128i*)(p+16), xmm0); \
|
||||||
|
+ _mm_storeu_si128((__m128i*)(p+32), xmm0); \
|
||||||
|
+ _mm_storeu_si128((__m128i*)(p+48), xmm0); \
|
||||||
|
+ p += 64; \
|
||||||
|
+ size -= 64; \
|
||||||
|
+ } while (size != 0); \
|
||||||
|
+ } \
|
||||||
|
} while (0)
|
||||||
|
#else
|
||||||
|
# define HT_HASH_RESET(ht) \
|
||||||
|
diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h
|
||||||
|
index d362b01643..3af90d705b 100644
|
||||||
|
--- a/Zend/zend_vm_def.h
|
||||||
|
+++ b/Zend/zend_vm_def.h
|
||||||
|
@@ -417,7 +417,7 @@ ZEND_VM_HANDLER(8, ZEND_CONCAT, CONST|TMPVAR|CV, CONST|TMPVAR|CV, SPEC(NO_CONST_
|
||||||
|
size_t len = ZSTR_LEN(op1_str);
|
||||||
|
|
||||||
|
if (UNEXPECTED(len > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
- zend_error_noreturn(E_ERROR, "Integer overflow in memory allocation");
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
}
|
||||||
|
str = zend_string_extend(op1_str, len + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str) + len, ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
@@ -426,6 +426,9 @@ ZEND_VM_HANDLER(8, ZEND_CONCAT, CONST|TMPVAR|CV, CONST|TMPVAR|CV, SPEC(NO_CONST_
|
||||||
|
zend_string_release_ex(op2_str, 0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
+ if (UNEXPECTED(ZSTR_LEN(op1_str) > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
+ }
|
||||||
|
str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str));
|
||||||
|
memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
@@ -3210,6 +3213,9 @@ ZEND_VM_COLD_CONSTCONST_HANDLER(53, ZEND_FAST_CONCAT, CONST|TMPVAR|CV, CONST|TMP
|
||||||
|
!ZSTR_IS_INTERNED(op1_str) && GC_REFCOUNT(op1_str) == 1) {
|
||||||
|
size_t len = ZSTR_LEN(op1_str);
|
||||||
|
|
||||||
|
+ if (UNEXPECTED(len > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
+ }
|
||||||
|
str = zend_string_extend(op1_str, len + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str) + len, ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
ZVAL_NEW_STR(EX_VAR(opline->result.var), str);
|
||||||
|
@@ -3217,6 +3223,9 @@ ZEND_VM_COLD_CONSTCONST_HANDLER(53, ZEND_FAST_CONCAT, CONST|TMPVAR|CV, CONST|TMP
|
||||||
|
zend_string_release_ex(op2_str, 0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
+ if (UNEXPECTED(ZSTR_LEN(op1_str) > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
+ }
|
||||||
|
str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str));
|
||||||
|
memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h
|
||||||
|
index 2875fd3740..8701e77ea8 100644
|
||||||
|
--- a/Zend/zend_vm_execute.h
|
||||||
|
+++ b/Zend/zend_vm_execute.h
|
||||||
|
@@ -5631,6 +5631,9 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_
|
||||||
|
!ZSTR_IS_INTERNED(op1_str) && GC_REFCOUNT(op1_str) == 1) {
|
||||||
|
size_t len = ZSTR_LEN(op1_str);
|
||||||
|
|
||||||
|
+ if (UNEXPECTED(len > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
+ }
|
||||||
|
str = zend_string_extend(op1_str, len + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str) + len, ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
ZVAL_NEW_STR(EX_VAR(opline->result.var), str);
|
||||||
|
@@ -5638,6 +5641,9 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_
|
||||||
|
zend_string_release_ex(op2_str, 0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
+ if (UNEXPECTED(ZSTR_LEN(op1_str) > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
+ }
|
||||||
|
str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str));
|
||||||
|
memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
@@ -7491,6 +7497,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CONCAT_SPEC_CONST_TMPVAR_HANDL
|
||||||
|
!ZSTR_IS_INTERNED(op1_str) && GC_REFCOUNT(op1_str) == 1) {
|
||||||
|
size_t len = ZSTR_LEN(op1_str);
|
||||||
|
|
||||||
|
+ if (UNEXPECTED(len > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
+ }
|
||||||
|
str = zend_string_extend(op1_str, len + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str) + len, ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
ZVAL_NEW_STR(EX_VAR(opline->result.var), str);
|
||||||
|
@@ -7498,6 +7507,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CONCAT_SPEC_CONST_TMPVAR_HANDL
|
||||||
|
zend_string_release_ex(op2_str, 0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
+ if (UNEXPECTED(ZSTR_LEN(op1_str) > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
+ }
|
||||||
|
str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str));
|
||||||
|
memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
@@ -7900,7 +7912,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CONST_TMPVAR_
|
||||||
|
size_t len = ZSTR_LEN(op1_str);
|
||||||
|
|
||||||
|
if (UNEXPECTED(len > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
- zend_error_noreturn(E_ERROR, "Integer overflow in memory allocation");
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
}
|
||||||
|
str = zend_string_extend(op1_str, len + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str) + len, ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
@@ -7909,6 +7921,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CONST_TMPVAR_
|
||||||
|
zend_string_release_ex(op2_str, 0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
+ if (UNEXPECTED(ZSTR_LEN(op1_str) > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
+ }
|
||||||
|
str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str));
|
||||||
|
memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
@@ -9952,6 +9967,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CONCAT_SPEC_CONST_CV_HANDLER(Z
|
||||||
|
!ZSTR_IS_INTERNED(op1_str) && GC_REFCOUNT(op1_str) == 1) {
|
||||||
|
size_t len = ZSTR_LEN(op1_str);
|
||||||
|
|
||||||
|
+ if (UNEXPECTED(len > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
+ }
|
||||||
|
str = zend_string_extend(op1_str, len + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str) + len, ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
ZVAL_NEW_STR(EX_VAR(opline->result.var), str);
|
||||||
|
@@ -9959,6 +9977,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CONCAT_SPEC_CONST_CV_HANDLER(Z
|
||||||
|
zend_string_release_ex(op2_str, 0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
+ if (UNEXPECTED(ZSTR_LEN(op1_str) > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
+ }
|
||||||
|
str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str));
|
||||||
|
memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
@@ -10361,7 +10382,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CONST_CV_HAND
|
||||||
|
size_t len = ZSTR_LEN(op1_str);
|
||||||
|
|
||||||
|
if (UNEXPECTED(len > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
- zend_error_noreturn(E_ERROR, "Integer overflow in memory allocation");
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
}
|
||||||
|
str = zend_string_extend(op1_str, len + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str) + len, ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
@@ -10370,6 +10391,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CONST_CV_HAND
|
||||||
|
zend_string_release_ex(op2_str, 0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
+ if (UNEXPECTED(ZSTR_LEN(op1_str) > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
+ }
|
||||||
|
str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str));
|
||||||
|
memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
@@ -13928,6 +13952,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CONCAT_SPEC_TMPVAR_CONST_HANDL
|
||||||
|
!ZSTR_IS_INTERNED(op1_str) && GC_REFCOUNT(op1_str) == 1) {
|
||||||
|
size_t len = ZSTR_LEN(op1_str);
|
||||||
|
|
||||||
|
+ if (UNEXPECTED(len > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
+ }
|
||||||
|
str = zend_string_extend(op1_str, len + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str) + len, ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
ZVAL_NEW_STR(EX_VAR(opline->result.var), str);
|
||||||
|
@@ -13935,6 +13962,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CONCAT_SPEC_TMPVAR_CONST_HANDL
|
||||||
|
zend_string_release_ex(op2_str, 0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
+ if (UNEXPECTED(ZSTR_LEN(op1_str) > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
+ }
|
||||||
|
str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str));
|
||||||
|
memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
@@ -14681,7 +14711,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_TMPVAR_CONST_
|
||||||
|
size_t len = ZSTR_LEN(op1_str);
|
||||||
|
|
||||||
|
if (UNEXPECTED(len > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
- zend_error_noreturn(E_ERROR, "Integer overflow in memory allocation");
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
}
|
||||||
|
str = zend_string_extend(op1_str, len + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str) + len, ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
@@ -14690,6 +14720,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_TMPVAR_CONST_
|
||||||
|
zend_string_release_ex(op2_str, 0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
+ if (UNEXPECTED(ZSTR_LEN(op1_str) > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
+ }
|
||||||
|
str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str));
|
||||||
|
memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
@@ -15353,7 +15386,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CONCAT_SPEC_TMPVAR_TMPVAR_HAND
|
||||||
|
size_t len = ZSTR_LEN(op1_str);
|
||||||
|
|
||||||
|
if (UNEXPECTED(len > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
- zend_error_noreturn(E_ERROR, "Integer overflow in memory allocation");
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
}
|
||||||
|
str = zend_string_extend(op1_str, len + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str) + len, ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
@@ -15362,6 +15395,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CONCAT_SPEC_TMPVAR_TMPVAR_HAND
|
||||||
|
zend_string_release_ex(op2_str, 0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
+ if (UNEXPECTED(ZSTR_LEN(op1_str) > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
+ }
|
||||||
|
str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str));
|
||||||
|
memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
@@ -16107,6 +16143,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_TMPVAR_TMPVAR
|
||||||
|
!ZSTR_IS_INTERNED(op1_str) && GC_REFCOUNT(op1_str) == 1) {
|
||||||
|
size_t len = ZSTR_LEN(op1_str);
|
||||||
|
|
||||||
|
+ if (UNEXPECTED(len > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
+ }
|
||||||
|
str = zend_string_extend(op1_str, len + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str) + len, ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
ZVAL_NEW_STR(EX_VAR(opline->result.var), str);
|
||||||
|
@@ -16114,6 +16153,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_TMPVAR_TMPVAR
|
||||||
|
zend_string_release_ex(op2_str, 0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
+ if (UNEXPECTED(ZSTR_LEN(op1_str) > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
+ }
|
||||||
|
str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str));
|
||||||
|
memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
@@ -17040,7 +17082,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CONCAT_SPEC_TMPVAR_CV_HANDLER(
|
||||||
|
size_t len = ZSTR_LEN(op1_str);
|
||||||
|
|
||||||
|
if (UNEXPECTED(len > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
- zend_error_noreturn(E_ERROR, "Integer overflow in memory allocation");
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
}
|
||||||
|
str = zend_string_extend(op1_str, len + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str) + len, ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
@@ -17049,6 +17091,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CONCAT_SPEC_TMPVAR_CV_HANDLER(
|
||||||
|
zend_string_release_ex(op2_str, 0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
+ if (UNEXPECTED(ZSTR_LEN(op1_str) > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
+ }
|
||||||
|
str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str));
|
||||||
|
memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
@@ -17401,6 +17446,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_TMPVAR_CV_HAN
|
||||||
|
!ZSTR_IS_INTERNED(op1_str) && GC_REFCOUNT(op1_str) == 1) {
|
||||||
|
size_t len = ZSTR_LEN(op1_str);
|
||||||
|
|
||||||
|
+ if (UNEXPECTED(len > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
+ }
|
||||||
|
str = zend_string_extend(op1_str, len + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str) + len, ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
ZVAL_NEW_STR(EX_VAR(opline->result.var), str);
|
||||||
|
@@ -17408,6 +17456,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_TMPVAR_CV_HAN
|
||||||
|
zend_string_release_ex(op2_str, 0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
+ if (UNEXPECTED(ZSTR_LEN(op1_str) > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
+ }
|
||||||
|
str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str));
|
||||||
|
memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
@@ -38348,7 +38399,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CONCAT_SPEC_CV_CONST_HANDLER(Z
|
||||||
|
size_t len = ZSTR_LEN(op1_str);
|
||||||
|
|
||||||
|
if (UNEXPECTED(len > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
- zend_error_noreturn(E_ERROR, "Integer overflow in memory allocation");
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
}
|
||||||
|
str = zend_string_extend(op1_str, len + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str) + len, ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
@@ -38357,6 +38408,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CONCAT_SPEC_CV_CONST_HANDLER(Z
|
||||||
|
zend_string_release_ex(op2_str, 0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
+ if (UNEXPECTED(ZSTR_LEN(op1_str) > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
+ }
|
||||||
|
str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str));
|
||||||
|
memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
@@ -40727,7 +40781,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CV_CONST_HAND
|
||||||
|
size_t len = ZSTR_LEN(op1_str);
|
||||||
|
|
||||||
|
if (UNEXPECTED(len > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
- zend_error_noreturn(E_ERROR, "Integer overflow in memory allocation");
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
}
|
||||||
|
str = zend_string_extend(op1_str, len + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str) + len, ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
@@ -40736,6 +40790,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CV_CONST_HAND
|
||||||
|
zend_string_release_ex(op2_str, 0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
+ if (UNEXPECTED(ZSTR_LEN(op1_str) > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
+ }
|
||||||
|
str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str));
|
||||||
|
memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
@@ -41849,6 +41906,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CONCAT_SPEC_CV_TMPVAR_HANDLER(
|
||||||
|
!ZSTR_IS_INTERNED(op1_str) && GC_REFCOUNT(op1_str) == 1) {
|
||||||
|
size_t len = ZSTR_LEN(op1_str);
|
||||||
|
|
||||||
|
+ if (UNEXPECTED(len > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
+ }
|
||||||
|
str = zend_string_extend(op1_str, len + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str) + len, ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
ZVAL_NEW_STR(EX_VAR(opline->result.var), str);
|
||||||
|
@@ -41856,6 +41916,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CONCAT_SPEC_CV_TMPVAR_HANDLER(
|
||||||
|
zend_string_release_ex(op2_str, 0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
+ if (UNEXPECTED(ZSTR_LEN(op1_str) > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
+ }
|
||||||
|
str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str));
|
||||||
|
memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
@@ -44132,6 +44195,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CV_TMPVAR_HAN
|
||||||
|
!ZSTR_IS_INTERNED(op1_str) && GC_REFCOUNT(op1_str) == 1) {
|
||||||
|
size_t len = ZSTR_LEN(op1_str);
|
||||||
|
|
||||||
|
+ if (UNEXPECTED(len > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
+ }
|
||||||
|
str = zend_string_extend(op1_str, len + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str) + len, ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
ZVAL_NEW_STR(EX_VAR(opline->result.var), str);
|
||||||
|
@@ -44139,6 +44205,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CV_TMPVAR_HAN
|
||||||
|
zend_string_release_ex(op2_str, 0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
+ if (UNEXPECTED(ZSTR_LEN(op1_str) > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
+ }
|
||||||
|
str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str));
|
||||||
|
memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
@@ -46857,7 +46926,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CONCAT_SPEC_CV_CV_HANDLER(ZEND
|
||||||
|
size_t len = ZSTR_LEN(op1_str);
|
||||||
|
|
||||||
|
if (UNEXPECTED(len > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
- zend_error_noreturn(E_ERROR, "Integer overflow in memory allocation");
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
}
|
||||||
|
str = zend_string_extend(op1_str, len + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str) + len, ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
@@ -46866,6 +46935,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CONCAT_SPEC_CV_CV_HANDLER(ZEND
|
||||||
|
zend_string_release_ex(op2_str, 0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
+ if (UNEXPECTED(ZSTR_LEN(op1_str) > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
+ }
|
||||||
|
str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str));
|
||||||
|
memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
@@ -49268,6 +49340,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CV_CV_HANDLER
|
||||||
|
!ZSTR_IS_INTERNED(op1_str) && GC_REFCOUNT(op1_str) == 1) {
|
||||||
|
size_t len = ZSTR_LEN(op1_str);
|
||||||
|
|
||||||
|
+ if (UNEXPECTED(len > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
+ }
|
||||||
|
str = zend_string_extend(op1_str, len + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str) + len, ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
ZVAL_NEW_STR(EX_VAR(opline->result.var), str);
|
||||||
|
@@ -49275,6 +49350,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CV_CV_HANDLER
|
||||||
|
zend_string_release_ex(op2_str, 0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
+ if (UNEXPECTED(ZSTR_LEN(op1_str) > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
+ }
|
||||||
|
str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str));
|
||||||
|
memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
diff --git a/ext/session/session.c b/ext/session/session.c
|
||||||
|
index 8fb6dd2cd5..89a7400a9c 100644
|
||||||
|
--- a/ext/session/session.c
|
||||||
|
+++ b/ext/session/session.c
|
||||||
|
@@ -3174,7 +3174,7 @@ static int php_session_rfc1867_callback(unsigned int event, void *event_data, vo
|
||||||
|
if (php_session_rfc1867_orig_callback) {
|
||||||
|
retval = php_session_rfc1867_orig_callback(event, event_data, extra);
|
||||||
|
}
|
||||||
|
- if (!PS(rfc1867_enabled)) {
|
||||||
|
+ if (!PS(rfc1867_enabled) || true) {
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/main/SAPI.c b/main/SAPI.c
|
||||||
|
index a5a68f8c68..1c320f6e3f 100644
|
||||||
|
--- a/main/SAPI.c
|
||||||
|
+++ b/main/SAPI.c
|
||||||
|
@@ -509,18 +509,23 @@ SAPI_API void sapi_deactivate(void)
|
||||||
|
}
|
||||||
|
if (SG(request_info).auth_user) {
|
||||||
|
efree(SG(request_info).auth_user);
|
||||||
|
+ SG(request_info).auth_user = NULL;
|
||||||
|
}
|
||||||
|
if (SG(request_info).auth_password) {
|
||||||
|
efree(SG(request_info).auth_password);
|
||||||
|
+ SG(request_info).auth_password = NULL;
|
||||||
|
}
|
||||||
|
if (SG(request_info).auth_digest) {
|
||||||
|
efree(SG(request_info).auth_digest);
|
||||||
|
+ SG(request_info).auth_digest = NULL;
|
||||||
|
}
|
||||||
|
if (SG(request_info).content_type_dup) {
|
||||||
|
efree(SG(request_info).content_type_dup);
|
||||||
|
+ SG(request_info).content_type_dup = NULL;
|
||||||
|
}
|
||||||
|
if (SG(request_info).current_user) {
|
||||||
|
efree(SG(request_info).current_user);
|
||||||
|
+ SG(request_info).current_user = NULL;
|
||||||
|
}
|
||||||
|
if (sapi_module.deactivate) {
|
||||||
|
sapi_module.deactivate();
|
||||||
|
diff --git a/main/main.c b/main/main.c
|
||||||
|
index 0b33b2b56c..bb8501f973 100644
|
||||||
|
--- a/main/main.c
|
||||||
|
+++ b/main/main.c
|
||||||
|
@@ -836,6 +836,7 @@ PHP_INI_BEGIN()
|
||||||
|
PHP_INI_ENTRY("disable_functions", "", PHP_INI_SYSTEM, NULL)
|
||||||
|
PHP_INI_ENTRY("disable_classes", "", PHP_INI_SYSTEM, NULL)
|
||||||
|
PHP_INI_ENTRY("max_file_uploads", "20", PHP_INI_SYSTEM|PHP_INI_PERDIR, NULL)
|
||||||
|
+ PHP_INI_ENTRY("max_multipart_body_parts", "-1", PHP_INI_SYSTEM|PHP_INI_PERDIR, NULL)
|
||||||
|
|
||||||
|
STD_PHP_INI_BOOLEAN("allow_url_fopen", "1", PHP_INI_SYSTEM, OnUpdateBool, allow_url_fopen, php_core_globals, core_globals)
|
||||||
|
STD_PHP_INI_BOOLEAN("allow_url_include", "0", PHP_INI_SYSTEM, OnUpdateBool, allow_url_include, php_core_globals, core_globals)
|
||||||
|
@@ -1960,6 +1961,8 @@ void php_request_shutdown(void *dummy)
|
||||||
|
|
||||||
|
for (i=0; i<NUM_TRACK_VARS; i++) {
|
||||||
|
zval_ptr_dtor(&PG(http_globals)[i]);
|
||||||
|
+ /* May be accessed before php_request_startup() */
|
||||||
|
+ ZVAL_UNDEF(&PG(http_globals)[i]);
|
||||||
|
}
|
||||||
|
} zend_end_try();
|
||||||
|
|
||||||
|
@@ -2012,6 +2015,9 @@ void php_request_shutdown(void *dummy)
|
||||||
|
#ifdef HAVE_DTRACE
|
||||||
|
DTRACE_REQUEST_SHUTDOWN(SAFE_FILENAME(SG(request_info).path_translated), SAFE_FILENAME(SG(request_info).request_uri), (char *)SAFE_FILENAME(SG(request_info).request_method));
|
||||||
|
#endif /* HAVE_DTRACE */
|
||||||
|
+
|
||||||
|
+ /* May be accessed before php_request_startup() */
|
||||||
|
+ PG(modules_activated) = 0;
|
||||||
|
}
|
||||||
|
/* }}} */
|
||||||
|
|
||||||
|
diff --git a/main/php_variables.c b/main/php_variables.c
|
||||||
|
index 18f6b65a6c..c920e4d5e2 100644
|
||||||
|
--- a/main/php_variables.c
|
||||||
|
+++ b/main/php_variables.c
|
||||||
|
@@ -218,7 +218,7 @@ PHPAPI void php_register_variable_ex(char *var_name, zval *val, zval *track_vars
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!index) {
|
||||||
|
- array_init(&gpc_element);
|
||||||
|
+ array_init_singleton(&gpc_element);
|
||||||
|
if ((gpc_element_p = zend_hash_next_index_insert(symtable1, &gpc_element)) == NULL) {
|
||||||
|
zend_array_destroy(Z_ARR(gpc_element));
|
||||||
|
zval_ptr_dtor_nogc(val);
|
||||||
|
@@ -229,7 +229,7 @@ PHPAPI void php_register_variable_ex(char *var_name, zval *val, zval *track_vars
|
||||||
|
gpc_element_p = zend_symtable_str_find(symtable1, index, index_len);
|
||||||
|
if (!gpc_element_p) {
|
||||||
|
zval tmp;
|
||||||
|
- array_init(&tmp);
|
||||||
|
+ array_init_singleton(&tmp);
|
||||||
|
gpc_element_p = zend_symtable_str_update_ind(symtable1, index, index_len, &tmp);
|
||||||
|
} else {
|
||||||
|
if (Z_TYPE_P(gpc_element_p) == IS_INDIRECT) {
|
||||||
|
@@ -237,7 +237,7 @@ PHPAPI void php_register_variable_ex(char *var_name, zval *val, zval *track_vars
|
||||||
|
}
|
||||||
|
if (Z_TYPE_P(gpc_element_p) != IS_ARRAY) {
|
||||||
|
zval_ptr_dtor_nogc(gpc_element_p);
|
||||||
|
- array_init(gpc_element_p);
|
||||||
|
+ array_init_singleton(gpc_element_p);
|
||||||
|
} else {
|
||||||
|
SEPARATE_ARRAY(gpc_element_p);
|
||||||
|
}
|
||||||
|
@@ -429,7 +429,7 @@ SAPI_API SAPI_TREAT_DATA_FUNC(php_default_treat_data)
|
||||||
|
case PARSE_POST:
|
||||||
|
case PARSE_GET:
|
||||||
|
case PARSE_COOKIE:
|
||||||
|
- array_init(&array);
|
||||||
|
+ array_init_singleton(&array);
|
||||||
|
switch (arg) {
|
||||||
|
case PARSE_POST:
|
||||||
|
zval_ptr_dtor_nogc(&PG(http_globals)[TRACK_VARS_POST]);
|
||||||
|
diff --git a/main/rfc1867.c b/main/rfc1867.c
|
||||||
|
index edef19c16d..4946df0ca2 100644
|
||||||
|
--- a/main/rfc1867.c
|
||||||
|
+++ b/main/rfc1867.c
|
||||||
|
@@ -397,6 +397,14 @@ static int find_boundary(multipart_buffer *self, char *boundary)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
+static zend_bool php_mime_should_save_hdr(const char *name)
|
||||||
|
+{
|
||||||
|
+ return !strcasecmp(name, "Content-Disposition")
|
||||||
|
+ || !strcasecmp(name, "Content-Type");
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static char *php_mime_get_hdr_value(zend_llist header, char *key);
|
||||||
|
+
|
||||||
|
/* parse headers */
|
||||||
|
static int multipart_buffer_headers(multipart_buffer *self, zend_llist *header)
|
||||||
|
{
|
||||||
|
@@ -437,10 +445,16 @@ static int multipart_buffer_headers(multipart_buffer *self, zend_llist *header)
|
||||||
|
}
|
||||||
|
|
||||||
|
*value = '\0';
|
||||||
|
- do { value++; } while (isspace(*value));
|
||||||
|
|
||||||
|
- key = estrdup(line);
|
||||||
|
- smart_string_appends(&buf_value, value);
|
||||||
|
+ /* Keep only headers we use, and ignore duplicates */
|
||||||
|
+ if (!php_mime_should_save_hdr(line)
|
||||||
|
+ || php_mime_get_hdr_value(*header, line)) {
|
||||||
|
+ key = NULL;
|
||||||
|
+ } else {
|
||||||
|
+ key = estrdup(line);
|
||||||
|
+ do { value++; } while (isspace((unsigned char)*value));
|
||||||
|
+ smart_string_appends(&buf_value, value);
|
||||||
|
+ }
|
||||||
|
} else if (buf_value.c) { /* If no ':' on the line, add to previous line */
|
||||||
|
smart_string_appends(&buf_value, line);
|
||||||
|
} else {
|
||||||
|
@@ -514,11 +528,11 @@ static char *php_ap_getword(const zend_encoding *encoding, char **line, char sto
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
-static char *substring_conf(char *start, int len, char quote)
|
||||||
|
+static char *substring_conf(char *start, size_t len, char quote)
|
||||||
|
{
|
||||||
|
char *result = emalloc(len + 1);
|
||||||
|
char *resp = result;
|
||||||
|
- int i;
|
||||||
|
+ size_t i;
|
||||||
|
|
||||||
|
for (i = 0; i < len && start[i] != quote; ++i) {
|
||||||
|
if (start[i] == '\\' && (start[i + 1] == '\\' || (quote && start[i + 1] == quote))) {
|
||||||
|
@@ -546,14 +560,14 @@ static char *php_ap_getword_conf(const zend_encoding *encoding, char *str)
|
||||||
|
char quote = *str;
|
||||||
|
|
||||||
|
str++;
|
||||||
|
- return substring_conf(str, (int)strlen(str), quote);
|
||||||
|
+ return substring_conf(str, strlen(str), quote);
|
||||||
|
} else {
|
||||||
|
char *strend = str;
|
||||||
|
|
||||||
|
while (*strend && !isspace(*strend)) {
|
||||||
|
++strend;
|
||||||
|
}
|
||||||
|
- return substring_conf(str, strend - str, 0);
|
||||||
|
+ return substring_conf(str, (size_t)(strend - str), 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -694,6 +708,7 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) /* {{{ */
|
||||||
|
void *event_extra_data = NULL;
|
||||||
|
unsigned int llen = 0;
|
||||||
|
int upload_cnt = INI_INT("max_file_uploads");
|
||||||
|
+ int body_parts_cnt = INI_INT("max_multipart_body_parts");
|
||||||
|
const zend_encoding *internal_encoding = zend_multibyte_get_internal_encoding();
|
||||||
|
php_rfc1867_getword_t getword;
|
||||||
|
php_rfc1867_getword_conf_t getword_conf;
|
||||||
|
@@ -715,6 +730,11 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) /* {{{ */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ if (body_parts_cnt < 0) {
|
||||||
|
+ body_parts_cnt = PG(max_input_vars) + upload_cnt;
|
||||||
|
+ }
|
||||||
|
+ int body_parts_limit = body_parts_cnt;
|
||||||
|
+
|
||||||
|
/* Get the boundary */
|
||||||
|
boundary = strstr(content_type_dup, "boundary");
|
||||||
|
if (!boundary) {
|
||||||
|
@@ -799,6 +819,11 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) /* {{{ */
|
||||||
|
char *pair = NULL;
|
||||||
|
int end = 0;
|
||||||
|
|
||||||
|
+ if (--body_parts_cnt < 0) {
|
||||||
|
+ php_error_docref(NULL, E_WARNING, "Multipart body parts limit exceeded %d. To increase the limit change max_multipart_body_parts in php.ini.", body_parts_limit);
|
||||||
|
+ goto fileupload_done;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
while (isspace(*cd)) {
|
||||||
|
++cd;
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
# Generated-file counterpart of the ext/pdo/pdo_sql_parser.re and
|
||||||
|
# ext/standard/url_scanner_ex.re hunks of php-7.4.33-sury-31.patch
|
||||||
|
# (so the fixes are built without re2c). Apply with -p1 after sury-31.
|
||||||
|
diff -ru a/ext/pdo/pdo_sql_parser.c b/ext/pdo/pdo_sql_parser.c
|
||||||
|
--- a/ext/pdo/pdo_sql_parser.c 2026-11-20 18:29:51.301889386 +0100
|
||||||
|
+++ b/ext/pdo/pdo_sql_parser.c 2026-11-20 18:29:51.311295846 +0100
|
||||||
|
@@ -398,7 +398,7 @@
|
||||||
|
|
||||||
|
if (t == PDO_PARSER_BIND) {
|
||||||
|
ptrdiff_t len = s.cur - s.tok;
|
||||||
|
- if ((inquery < (s.cur - len)) && isalnum(*(s.cur - len - 1))) {
|
||||||
|
+ if ((inquery < (s.cur - len)) && isalnum((unsigned char)s.cur[-len - 1])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
query_type |= PDO_PLACEHOLDER_NAMED;
|
||||||
|
diff -ru a/ext/standard/url_scanner_ex.c b/ext/standard/url_scanner_ex.c
|
||||||
|
--- a/ext/standard/url_scanner_ex.c 2026-11-20 18:29:51.305135831 +0100
|
||||||
|
+++ b/ext/standard/url_scanner_ex.c 2026-11-20 18:29:51.314432610 +0100
|
||||||
|
@@ -88,7 +88,7 @@
|
||||||
|
|
||||||
|
*val++ = '\0';
|
||||||
|
for (q = key; *q; q++) {
|
||||||
|
- *q = tolower(*q);
|
||||||
|
+ *q = tolower((unsigned char)*q);
|
||||||
|
}
|
||||||
|
keylen = q - key;
|
||||||
|
str = zend_string_init(key, keylen, 1);
|
||||||
|
@@ -137,7 +137,7 @@
|
||||||
|
char *q;
|
||||||
|
|
||||||
|
for (q = key; *q; q++) {
|
||||||
|
- *q = tolower(*q);
|
||||||
|
+ *q = tolower((unsigned char)*q);
|
||||||
|
}
|
||||||
|
keylen = q - key;
|
||||||
|
if (keylen > 0) {
|
||||||
|
@@ -451,7 +451,7 @@
|
||||||
|
}
|
||||||
|
smart_str_appendl(&ctx->tag, start, YYCURSOR - start);
|
||||||
|
for (i = 0; i < ZSTR_LEN(ctx->tag.s); i++)
|
||||||
|
- ZSTR_VAL(ctx->tag.s)[i] = tolower((int)(unsigned char)ZSTR_VAL(ctx->tag.s)[i]);
|
||||||
|
+ ZSTR_VAL(ctx->tag.s)[i] = tolower((unsigned char)ZSTR_VAL(ctx->tag.s)[i]);
|
||||||
|
/* intentionally using str_find here, in case the hash value is set, but the string val is changed later */
|
||||||
|
if ((ctx->lookup_data = zend_hash_str_find_ptr(ctx->tags, ZSTR_VAL(ctx->tag.s), ZSTR_LEN(ctx->tag.s))) != NULL) {
|
||||||
|
ok = 1;
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,100 @@
|
|||||||
|
diff --git a/ext/mysqli/tests/mysqlnd_row_decode_failure_refetch.phpt b/ext/mysqli/tests/mysqlnd_row_decode_failure_refetch.phpt
|
||||||
|
new file mode 100644
|
||||||
|
index 00000000..12ce0b0b
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/ext/mysqli/tests/mysqlnd_row_decode_failure_refetch.phpt
|
||||||
|
@@ -0,0 +1,34 @@
|
||||||
|
+--TEST--
|
||||||
|
+mysqlnd: a row whose decoding failed is decoded again, never served from freed fields
|
||||||
|
+--EXTENSIONS--
|
||||||
|
+mysqli
|
||||||
|
+--FILE--
|
||||||
|
+<?php
|
||||||
|
+require_once 'fake_server.inc';
|
||||||
|
+
|
||||||
|
+$port = 33305;
|
||||||
|
+$process = run_fake_server_in_background('stmt_response_row_over_read_int', $port);
|
||||||
|
+$process->wait();
|
||||||
|
+
|
||||||
|
+$conn = new mysqli("127.0.0.1", "root", "", "", $port);
|
||||||
|
+$stmt = $conn->prepare("SELECT strval, intval FROM data");
|
||||||
|
+$stmt->execute();
|
||||||
|
+$result = $stmt->get_result();
|
||||||
|
+
|
||||||
|
+$first = @$result->fetch_assoc();
|
||||||
|
+var_dump($first);
|
||||||
|
+$result->data_seek(0);
|
||||||
|
+$second = @$result->fetch_assoc();
|
||||||
|
+var_dump($second);
|
||||||
|
+
|
||||||
|
+$result->free();
|
||||||
|
+$stmt->close();
|
||||||
|
+$conn->close();
|
||||||
|
+$process->terminate(true);
|
||||||
|
+print "done!";
|
||||||
|
+?>
|
||||||
|
+--EXPECTF--
|
||||||
|
+%A
|
||||||
|
+bool(false)
|
||||||
|
+bool(false)
|
||||||
|
+%Adone!%A
|
||||||
|
diff --git a/ext/mysqlnd/mysqlnd_wireprotocol.c b/ext/mysqlnd/mysqlnd_wireprotocol.c
|
||||||
|
index 75dbe5e4..4a7fe087 100644
|
||||||
|
--- a/ext/mysqlnd/mysqlnd_wireprotocol.c
|
||||||
|
+++ b/ext/mysqlnd/mysqlnd_wireprotocol.c
|
||||||
|
@@ -1605,6 +1605,8 @@ php_mysqlnd_rowp_read_binary_protocol(MYSQLND_ROW_BUFFER * row_buffer, zval * fi
|
||||||
|
if (rbs <= row_position) {
|
||||||
|
for (j = 0, current_field = start_field; j < i; current_field++, j++) {
|
||||||
|
zval_ptr_dtor(current_field);
|
||||||
|
+ /* the caller keeps this array and frees it again later */
|
||||||
|
+ ZVAL_UNDEF(current_field);
|
||||||
|
}
|
||||||
|
php_error_docref(NULL, E_WARNING, "Malformed server packet. No packet space left for the field");
|
||||||
|
DBG_RETURN(FAIL);
|
||||||
|
@@ -1613,6 +1615,8 @@ php_mysqlnd_rowp_read_binary_protocol(MYSQLND_ROW_BUFFER * row_buffer, zval * fi
|
||||||
|
if (p == NULL) {
|
||||||
|
for (j = 0, current_field = start_field; j < i; current_field++, j++) {
|
||||||
|
zval_ptr_dtor(current_field);
|
||||||
|
+ /* the caller keeps this array and frees it again later */
|
||||||
|
+ ZVAL_UNDEF(current_field);
|
||||||
|
}
|
||||||
|
DBG_RETURN(FAIL);
|
||||||
|
}
|
||||||
|
@@ -1697,6 +1701,8 @@ php_mysqlnd_rowp_read_text_protocol_aux(MYSQLND_ROW_BUFFER * row_buffer, zval *
|
||||||
|
php_error_docref(NULL, E_WARNING, "Malformed server packet. Field length pointing after end of packet");
|
||||||
|
for (j = 0, current_field = start_field; j < i; current_field++, j++) {
|
||||||
|
zval_ptr_dtor(current_field);
|
||||||
|
+ /* the caller keeps this array and frees it again later */
|
||||||
|
+ ZVAL_UNDEF(current_field);
|
||||||
|
}
|
||||||
|
DBG_RETURN(FAIL);
|
||||||
|
} else {
|
||||||
|
diff --git a/sapi/cli/php_cli_server.c b/sapi/cli/php_cli_server.c
|
||||||
|
index 2ea81763..b4634c64 100644
|
||||||
|
--- a/sapi/cli/php_cli_server.c
|
||||||
|
+++ b/sapi/cli/php_cli_server.c
|
||||||
|
@@ -517,13 +517,8 @@ static int sapi_cli_server_startup(sapi_module_struct *sapi_module) /* {{{ */
|
||||||
|
if (php_cli_server_workers_max > 1) {
|
||||||
|
zend_long php_cli_server_worker;
|
||||||
|
|
||||||
|
- php_cli_server_workers = calloc(
|
||||||
|
- php_cli_server_workers_max, sizeof(pid_t));
|
||||||
|
- if (!php_cli_server_workers) {
|
||||||
|
- php_cli_server_workers_max = 1;
|
||||||
|
-
|
||||||
|
- return SUCCESS;
|
||||||
|
- }
|
||||||
|
+ php_cli_server_workers = pecalloc(
|
||||||
|
+ php_cli_server_workers_max, sizeof(pid_t), 1);
|
||||||
|
|
||||||
|
php_cli_server_master = getpid();
|
||||||
|
|
||||||
|
@@ -2357,7 +2352,7 @@ static void php_cli_server_dtor(php_cli_server *server) /* {{{ */
|
||||||
|
!WIFSIGNALED(php_cli_server_worker_status));
|
||||||
|
}
|
||||||
|
|
||||||
|
- free(php_cli_server_workers);
|
||||||
|
+ pefree(php_cli_server_workers, 1);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
} /* }}} */
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,910 @@
|
|||||||
|
diff --git a/Zend/zend_API.h b/Zend/zend_API.h
|
||||||
|
index 456ef05d80..0d015bacf3 100644
|
||||||
|
--- a/Zend/zend_API.h
|
||||||
|
+++ b/Zend/zend_API.h
|
||||||
|
@@ -428,6 +428,7 @@ ZEND_API const char *zend_get_type_by_const(int type);
|
||||||
|
|
||||||
|
#define array_init(arg) ZVAL_ARR((arg), zend_new_array(0))
|
||||||
|
#define array_init_size(arg, size) ZVAL_ARR((arg), zend_new_array(size))
|
||||||
|
+#define array_init_singleton(arg) ZVAL_ARR((arg), zend_new_array_singleton())
|
||||||
|
ZEND_API void object_init(zval *arg);
|
||||||
|
ZEND_API zend_result object_init_ex(zval *arg, zend_class_entry *ce);
|
||||||
|
ZEND_API zend_result object_and_properties_init(zval *arg, zend_class_entry *ce, HashTable *properties);
|
||||||
|
diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c
|
||||||
|
index 6e0ce4b651..a21b10f9be 100644
|
||||||
|
--- a/Zend/zend_alloc.c
|
||||||
|
+++ b/Zend/zend_alloc.c
|
||||||
|
@@ -57,6 +57,7 @@
|
||||||
|
#include "zend_operators.h"
|
||||||
|
#include "zend_multiply.h"
|
||||||
|
#include "zend_bitset.h"
|
||||||
|
+#include "zend_execute.h"
|
||||||
|
#include <signal.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_UNISTD_H
|
||||||
|
@@ -363,7 +364,42 @@ static ZEND_COLD ZEND_NORETURN void zend_mm_panic(const char *message)
|
||||||
|
#if ZEND_DEBUG && defined(HAVE_KILL) && defined(HAVE_GETPID)
|
||||||
|
kill(getpid(), SIGSEGV);
|
||||||
|
#endif
|
||||||
|
- exit(1);
|
||||||
|
+ _exit(1);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+ZEND_API ZEND_COLD ZEND_NORETURN void zend_mm_safe_error_ex(const char *format, ...)
|
||||||
|
+{
|
||||||
|
+ zend_string *script_filename = NULL;
|
||||||
|
+ uint32_t script_lineno = 0;
|
||||||
|
+
|
||||||
|
+ if (zend_is_executing()) {
|
||||||
|
+ script_filename = zend_get_executed_filename_ex();
|
||||||
|
+ script_lineno = zend_get_executed_lineno();
|
||||||
|
+ } else if (zend_is_compiling()) {
|
||||||
|
+ script_filename = zend_get_compiled_filename();
|
||||||
|
+ script_lineno = zend_get_compiled_lineno();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ va_list args;
|
||||||
|
+ va_start(args, format);
|
||||||
|
+
|
||||||
|
+ char buf[1024];
|
||||||
|
+ vsnprintf(buf, sizeof(buf), format, args);
|
||||||
|
+
|
||||||
|
+ va_end(args);
|
||||||
|
+
|
||||||
|
+ fprintf(stderr,
|
||||||
|
+ "\nFatal error: %s in %s on line %d\n",
|
||||||
|
+ buf,
|
||||||
|
+ script_filename ? ZSTR_VAL(script_filename) : "Unknown",
|
||||||
|
+ script_lineno);
|
||||||
|
+
|
||||||
|
+ /* See http://support.microsoft.com/kb/190351 */
|
||||||
|
+# ifdef ZEND_WIN32
|
||||||
|
+ fflush(stderr);
|
||||||
|
+# endif
|
||||||
|
+
|
||||||
|
+ _exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static ZEND_COLD ZEND_NORETURN void zend_mm_safe_error(zend_mm_heap *heap,
|
||||||
|
@@ -375,22 +411,14 @@ static ZEND_COLD ZEND_NORETURN void zend_mm_safe_error(zend_mm_heap *heap,
|
||||||
|
#endif
|
||||||
|
size_t size)
|
||||||
|
{
|
||||||
|
+ (void) heap;
|
||||||
|
|
||||||
|
- heap->overflow = 1;
|
||||||
|
- zend_try {
|
||||||
|
- zend_error_noreturn(E_ERROR,
|
||||||
|
- format,
|
||||||
|
- limit,
|
||||||
|
+ zend_mm_safe_error_ex(format, limit,
|
||||||
|
#if ZEND_DEBUG
|
||||||
|
- filename,
|
||||||
|
- lineno,
|
||||||
|
+ filename,
|
||||||
|
+ lineno,
|
||||||
|
#endif
|
||||||
|
- size);
|
||||||
|
- } zend_catch {
|
||||||
|
- } zend_end_try();
|
||||||
|
- heap->overflow = 0;
|
||||||
|
- zend_bailout();
|
||||||
|
- exit(1);
|
||||||
|
+ size);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
@@ -1318,7 +1346,7 @@ static zend_always_inline void *zend_mm_alloc_heap(zend_mm_heap *heap, size_t si
|
||||||
|
size = MAX(size, 1);
|
||||||
|
size = ZEND_MM_ALIGNED_SIZE(size) + ZEND_MM_ALIGNED_SIZE(sizeof(zend_mm_debug_info));
|
||||||
|
if (UNEXPECTED(size < real_size)) {
|
||||||
|
- zend_error_noreturn(E_ERROR, "Possible integer overflow in memory allocation (%zu + %zu)", ZEND_MM_ALIGNED_SIZE(real_size), ZEND_MM_ALIGNED_SIZE(sizeof(zend_mm_debug_info)));
|
||||||
|
+ zend_mm_safe_error_ex("Possible integer overflow in memory allocation (%zu + %zu)", ZEND_MM_ALIGNED_SIZE(real_size), ZEND_MM_ALIGNED_SIZE(sizeof(zend_mm_debug_info)));
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
@@ -1762,7 +1790,7 @@ static void *zend_mm_alloc_huge(zend_mm_heap *heap, size_t size ZEND_FILE_LINE_D
|
||||||
|
void *ptr;
|
||||||
|
|
||||||
|
if (UNEXPECTED(new_size < size)) {
|
||||||
|
- zend_error_noreturn(E_ERROR, "Possible integer overflow in memory allocation (%zu + %zu)", size, alignment);
|
||||||
|
+ zend_mm_safe_error_ex("Possible integer overflow in memory allocation (%zu + %zu)", size, alignment);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if ZEND_MM_LIMIT
|
||||||
|
@@ -2618,7 +2646,7 @@ ZEND_API char* ZEND_FASTCALL _estrdup(const char *s ZEND_FILE_LINE_DC ZEND_FILE_
|
||||||
|
|
||||||
|
length = strlen(s);
|
||||||
|
if (UNEXPECTED(length + 1 == 0)) {
|
||||||
|
- zend_error_noreturn(E_ERROR, "Possible integer overflow in memory allocation (1 * %zu + 1)", length);
|
||||||
|
+ zend_mm_safe_error_ex("Possible integer overflow in memory allocation (1 * %zu + 1)", length);
|
||||||
|
}
|
||||||
|
p = (char *) _emalloc(length + 1 ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
|
||||||
|
memcpy(p, s, length+1);
|
||||||
|
@@ -2630,7 +2658,7 @@ ZEND_API char* ZEND_FASTCALL _estrndup(const char *s, size_t length ZEND_FILE_LI
|
||||||
|
char *p;
|
||||||
|
|
||||||
|
if (UNEXPECTED(length + 1 == 0)) {
|
||||||
|
- zend_error_noreturn(E_ERROR, "Possible integer overflow in memory allocation (1 * %zu + 1)", length);
|
||||||
|
+ zend_mm_safe_error_ex("Possible integer overflow in memory allocation (1 * %zu + 1)", length);
|
||||||
|
}
|
||||||
|
p = (char *) _emalloc(length + 1 ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
|
||||||
|
memcpy(p, s, length);
|
||||||
|
@@ -2644,7 +2672,7 @@ ZEND_API char* ZEND_FASTCALL zend_strndup(const char *s, size_t length)
|
||||||
|
char *p;
|
||||||
|
|
||||||
|
if (UNEXPECTED(length + 1 == 0)) {
|
||||||
|
- zend_error_noreturn(E_ERROR, "Possible integer overflow in memory allocation (1 * %zu + 1)", length);
|
||||||
|
+ zend_mm_safe_error_ex("Possible integer overflow in memory allocation (1 * %zu + 1)", length);
|
||||||
|
}
|
||||||
|
p = (char *) malloc(length + 1);
|
||||||
|
if (UNEXPECTED(p == NULL)) {
|
||||||
|
@@ -3048,7 +3076,7 @@ ZEND_API zend_mm_heap *zend_mm_startup_ex(const zend_mm_handlers *handlers, void
|
||||||
|
static ZEND_COLD ZEND_NORETURN void zend_out_of_memory(void)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Out of memory\n");
|
||||||
|
- exit(1);
|
||||||
|
+ _exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
ZEND_API void * __zend_malloc(size_t len)
|
||||||
|
diff --git a/Zend/zend_alloc.h b/Zend/zend_alloc.h
|
||||||
|
index de450bbca2..f6bc82d250 100644
|
||||||
|
--- a/Zend/zend_alloc.h
|
||||||
|
+++ b/Zend/zend_alloc.h
|
||||||
|
@@ -403,6 +403,8 @@ static void apc_init_heap(void)
|
||||||
|
size_t zend_mm_globals_size(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
+ZEND_API ZEND_COLD ZEND_NORETURN void zend_mm_safe_error_ex(const char *format, ...);
|
||||||
|
+
|
||||||
|
END_EXTERN_C()
|
||||||
|
|
||||||
|
#endif
|
||||||
|
diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c
|
||||||
|
index 18104c2d99..2f19a17c6b 100644
|
||||||
|
--- a/Zend/zend_execute_API.c
|
||||||
|
+++ b/Zend/zend_execute_API.c
|
||||||
|
@@ -334,10 +334,21 @@ void shutdown_executor(void) /* {{{ */
|
||||||
|
gc_collect_cycles();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
+ } else {
|
||||||
|
+ /* may be used by zend_error_zstr_at before init_executor */
|
||||||
|
+ ZVAL_UNDEF(&EG(user_error_handler));
|
||||||
|
+ ZVAL_UNDEF(&EG(user_exception_handler));
|
||||||
|
+ memset(&EG(user_error_handlers_error_reporting), 0, sizeof(EG(user_error_handlers_error_reporting)));
|
||||||
|
+ memset(&EG(user_error_handlers), 0, sizeof(EG(user_error_handlers)));
|
||||||
|
+ memset(&EG(user_exception_handlers), 0, sizeof(EG(user_exception_handlers)));
|
||||||
|
}
|
||||||
|
|
||||||
|
zend_objects_store_free_object_storage(&EG(objects_store), fast_shutdown);
|
||||||
|
|
||||||
|
+ /* may be used by zend_error_zstr_at before init_executor */
|
||||||
|
+ EG(error_handling) = EH_NORMAL;
|
||||||
|
+ EG(exception) = NULL;
|
||||||
|
+
|
||||||
|
zend_weakrefs_shutdown();
|
||||||
|
|
||||||
|
zend_try {
|
||||||
|
@@ -354,6 +365,8 @@ void shutdown_executor(void) /* {{{ */
|
||||||
|
zend_hash_discard(EG(function_table), EG(persistent_functions_count));
|
||||||
|
zend_hash_discard(EG(class_table), EG(persistent_classes_count));
|
||||||
|
zend_cleanup_internal_classes();
|
||||||
|
+ EG(objects_store).object_buckets = NULL;
|
||||||
|
+ EG(objects_store).top = 1;
|
||||||
|
} else {
|
||||||
|
zend_vm_stack_destroy();
|
||||||
|
|
||||||
|
diff --git a/Zend/zend_hash.c b/Zend/zend_hash.c
|
||||||
|
index a3b62160dc..a4c318d123 100644
|
||||||
|
--- a/Zend/zend_hash.c
|
||||||
|
+++ b/Zend/zend_hash.c
|
||||||
|
@@ -119,7 +119,7 @@ static zend_always_inline uint32_t zend_hash_check_size(uint32_t nSize)
|
||||||
|
if (nSize <= HT_MIN_SIZE) {
|
||||||
|
return HT_MIN_SIZE;
|
||||||
|
} else if (UNEXPECTED(nSize >= HT_MAX_SIZE)) {
|
||||||
|
- zend_error_noreturn(E_ERROR, "Possible integer overflow in memory allocation (%u * %zu + %zu)", nSize, sizeof(Bucket), sizeof(Bucket));
|
||||||
|
+ zend_mm_safe_error_ex("Possible integer overflow in memory allocation (%u * %zu + %zu)", nSize, sizeof(Bucket), sizeof(Bucket));
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef ZEND_WIN32
|
||||||
|
@@ -273,6 +273,13 @@ ZEND_API HashTable* ZEND_FASTCALL _zend_new_array_0(void)
|
||||||
|
return ht;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ZEND_API HashTable* ZEND_FASTCALL zend_new_array_singleton(void)
|
||||||
|
+{
|
||||||
|
+ HashTable *ht = _zend_new_array_0();
|
||||||
|
+ ht->nTableSize = 1;
|
||||||
|
+ return ht;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
ZEND_API HashTable* ZEND_FASTCALL _zend_new_array(uint32_t nSize)
|
||||||
|
{
|
||||||
|
HashTable *ht = emalloc(sizeof(HashTable));
|
||||||
|
@@ -304,7 +311,7 @@ static void ZEND_FASTCALL zend_hash_packed_grow(HashTable *ht)
|
||||||
|
{
|
||||||
|
HT_ASSERT_RC1(ht);
|
||||||
|
if (ht->nTableSize >= HT_MAX_SIZE) {
|
||||||
|
- zend_error_noreturn(E_ERROR, "Possible integer overflow in memory allocation (%u * %zu + %zu)", ht->nTableSize * 2, sizeof(Bucket), sizeof(Bucket));
|
||||||
|
+ zend_mm_safe_error_ex("Possible integer overflow in memory allocation (%u * %zu + %zu)", ht->nTableSize * 2, sizeof(Bucket), sizeof(Bucket));
|
||||||
|
}
|
||||||
|
ht->nTableSize += ht->nTableSize;
|
||||||
|
HT_SET_DATA_ADDR(ht, perealloc2(HT_GET_DATA_ADDR(ht), HT_SIZE_EX(ht->nTableSize, HT_MIN_MASK), HT_USED_SIZE(ht), GC_FLAGS(ht) & IS_ARRAY_PERSISTENT));
|
||||||
|
@@ -1190,7 +1197,7 @@ static void ZEND_FASTCALL zend_hash_do_resize(HashTable *ht)
|
||||||
|
pefree(old_data, GC_FLAGS(ht) & IS_ARRAY_PERSISTENT);
|
||||||
|
zend_hash_rehash(ht);
|
||||||
|
} else {
|
||||||
|
- zend_error_noreturn(E_ERROR, "Possible integer overflow in memory allocation (%u * %zu + %zu)", ht->nTableSize * 2, sizeof(Bucket) + sizeof(uint32_t), sizeof(Bucket));
|
||||||
|
+ zend_mm_safe_error_ex("Possible integer overflow in memory allocation (%u * %zu + %zu)", ht->nTableSize * 2, sizeof(Bucket) + sizeof(uint32_t), sizeof(Bucket));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/Zend/zend_hash.h b/Zend/zend_hash.h
|
||||||
|
index ced21a2ca1..b697acf587 100644
|
||||||
|
--- a/Zend/zend_hash.h
|
||||||
|
+++ b/Zend/zend_hash.h
|
||||||
|
@@ -296,6 +296,7 @@ ZEND_API void ZEND_FASTCALL zend_hash_rehash(HashTable *ht);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ZEND_API HashTable* ZEND_FASTCALL _zend_new_array_0(void);
|
||||||
|
+ZEND_API HashTable* ZEND_FASTCALL zend_new_array_singleton(void);
|
||||||
|
ZEND_API HashTable* ZEND_FASTCALL _zend_new_array(uint32_t size);
|
||||||
|
ZEND_API HashTable* ZEND_FASTCALL zend_new_pair(zval *val1, zval *val2);
|
||||||
|
ZEND_API uint32_t zend_array_count(HashTable *ht);
|
||||||
|
diff --git a/Zend/zend_llist.c b/Zend/zend_llist.c
|
||||||
|
index 78a3310438..8c42b2494e 100644
|
||||||
|
--- a/Zend/zend_llist.c
|
||||||
|
+++ b/Zend/zend_llist.c
|
||||||
|
@@ -112,6 +112,8 @@ ZEND_API void zend_llist_destroy(zend_llist *l)
|
||||||
|
current = next;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ l->head = NULL;
|
||||||
|
+ l->tail = NULL;
|
||||||
|
l->count = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/Zend/zend_multiply.h b/Zend/zend_multiply.h
|
||||||
|
index c6cd472a23..bfe1b8e886 100644
|
||||||
|
--- a/Zend/zend_multiply.h
|
||||||
|
+++ b/Zend/zend_multiply.h
|
||||||
|
@@ -321,7 +321,7 @@ static zend_always_inline size_t zend_safe_address_guarded(size_t nmemb, size_t
|
||||||
|
size_t ret = zend_safe_address(nmemb, size, offset, &overflow);
|
||||||
|
|
||||||
|
if (UNEXPECTED(overflow)) {
|
||||||
|
- zend_error_noreturn(E_ERROR, "Possible integer overflow in memory allocation (%zu * %zu + %zu)", nmemb, size, offset);
|
||||||
|
+ zend_mm_safe_error_ex("Possible integer overflow in memory allocation (%zu * %zu + %zu)", nmemb, size, offset);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
@@ -334,7 +334,7 @@ static zend_always_inline size_t zend_safe_addmult(size_t nmemb, size_t size, si
|
||||||
|
size_t ret = zend_safe_address(nmemb, size, offset, &overflow);
|
||||||
|
|
||||||
|
if (UNEXPECTED(overflow)) {
|
||||||
|
- zend_error_noreturn(E_ERROR, "Possible integer overflow in %s (%zu * %zu + %zu)", message, nmemb, size, offset);
|
||||||
|
+ zend_mm_safe_error_ex("Possible integer overflow in %s (%zu * %zu + %zu)", message, nmemb, size, offset);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
diff --git a/Zend/zend_strtod.c b/Zend/zend_strtod.c
|
||||||
|
index e88fbd001f..fd6b23c9cb 100644
|
||||||
|
--- a/Zend/zend_strtod.c
|
||||||
|
+++ b/Zend/zend_strtod.c
|
||||||
|
@@ -603,7 +603,7 @@ Balloc
|
||||||
|
rv = (Bigint *)MALLOC(sizeof(Bigint) + (x-1)*sizeof(ULong));
|
||||||
|
if (!rv) {
|
||||||
|
FREE_DTOA_LOCK(0);
|
||||||
|
- zend_error_noreturn(E_ERROR, "Balloc() failed to allocate memory");
|
||||||
|
+ zend_mm_safe_error_ex("Balloc() failed to allocate memory");
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
len = (sizeof(Bigint) + (x-1)*sizeof(ULong) + sizeof(double) - 1)
|
||||||
|
@@ -616,7 +616,7 @@ Balloc
|
||||||
|
rv = (Bigint*)MALLOC(len*sizeof(double));
|
||||||
|
if (!rv) {
|
||||||
|
FREE_DTOA_LOCK(0);
|
||||||
|
- zend_error_noreturn(E_ERROR, "Balloc() failed to allocate memory");
|
||||||
|
+ zend_mm_safe_error_ex("Balloc() failed to allocate memory");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
rv->k = k;
|
||||||
|
diff --git a/Zend/zend_types.h b/Zend/zend_types.h
|
||||||
|
index 82cf20f1b5..1a10ba718c 100644
|
||||||
|
--- a/Zend/zend_types.h
|
||||||
|
+++ b/Zend/zend_types.h
|
||||||
|
@@ -439,17 +439,21 @@ struct _zend_array {
|
||||||
|
# define HT_HASH_RESET(ht) do { \
|
||||||
|
char *p = (char*)&HT_HASH(ht, (ht)->nTableMask); \
|
||||||
|
size_t size = HT_HASH_SIZE((ht)->nTableMask); \
|
||||||
|
- __m128i xmm0 = _mm_setzero_si128(); \
|
||||||
|
- xmm0 = _mm_cmpeq_epi8(xmm0, xmm0); \
|
||||||
|
- ZEND_ASSERT(size >= 64 && ((size & 0x3f) == 0)); \
|
||||||
|
- do { \
|
||||||
|
- _mm_storeu_si128((__m128i*)p, xmm0); \
|
||||||
|
- _mm_storeu_si128((__m128i*)(p+16), xmm0); \
|
||||||
|
- _mm_storeu_si128((__m128i*)(p+32), xmm0); \
|
||||||
|
- _mm_storeu_si128((__m128i*)(p+48), xmm0); \
|
||||||
|
- p += 64; \
|
||||||
|
- size -= 64; \
|
||||||
|
- } while (size != 0); \
|
||||||
|
+ if (UNEXPECTED(size < 64)) { \
|
||||||
|
+ memset(p, HT_INVALID_IDX, size); \
|
||||||
|
+ } else { \
|
||||||
|
+ __m128i xmm0 = _mm_setzero_si128(); \
|
||||||
|
+ xmm0 = _mm_cmpeq_epi8(xmm0, xmm0); \
|
||||||
|
+ ZEND_ASSERT(size >= 64 && ((size & 0x3f) == 0)); \
|
||||||
|
+ do { \
|
||||||
|
+ _mm_storeu_si128((__m128i*)p, xmm0); \
|
||||||
|
+ _mm_storeu_si128((__m128i*)(p+16), xmm0); \
|
||||||
|
+ _mm_storeu_si128((__m128i*)(p+32), xmm0); \
|
||||||
|
+ _mm_storeu_si128((__m128i*)(p+48), xmm0); \
|
||||||
|
+ p += 64; \
|
||||||
|
+ size -= 64; \
|
||||||
|
+ } while (size != 0); \
|
||||||
|
+ } \
|
||||||
|
} while (0)
|
||||||
|
#else
|
||||||
|
# define HT_HASH_RESET(ht) \
|
||||||
|
diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h
|
||||||
|
index bcb9be8dab..406350ef26 100644
|
||||||
|
--- a/Zend/zend_vm_def.h
|
||||||
|
+++ b/Zend/zend_vm_def.h
|
||||||
|
@@ -408,7 +408,7 @@ ZEND_VM_HANDLER(8, ZEND_CONCAT, CONST|TMPVAR|CV, CONST|TMPVAR|CV, SPEC(NO_CONST_
|
||||||
|
size_t len = ZSTR_LEN(op1_str);
|
||||||
|
|
||||||
|
if (UNEXPECTED(len > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
- zend_error_noreturn(E_ERROR, "Integer overflow in memory allocation");
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
}
|
||||||
|
str = zend_string_extend(op1_str, len + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str) + len, ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
@@ -417,6 +417,9 @@ ZEND_VM_HANDLER(8, ZEND_CONCAT, CONST|TMPVAR|CV, CONST|TMPVAR|CV, SPEC(NO_CONST_
|
||||||
|
zend_string_release_ex(op2_str, 0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
+ if (UNEXPECTED(ZSTR_LEN(op1_str) > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
+ }
|
||||||
|
str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str));
|
||||||
|
memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
@@ -3157,6 +3160,9 @@ ZEND_VM_COLD_CONSTCONST_HANDLER(53, ZEND_FAST_CONCAT, CONST|TMPVAR|CV, CONST|TMP
|
||||||
|
!ZSTR_IS_INTERNED(op1_str) && GC_REFCOUNT(op1_str) == 1) {
|
||||||
|
size_t len = ZSTR_LEN(op1_str);
|
||||||
|
|
||||||
|
+ if (UNEXPECTED(len > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
+ }
|
||||||
|
str = zend_string_extend(op1_str, len + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str) + len, ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
ZVAL_NEW_STR(EX_VAR(opline->result.var), str);
|
||||||
|
@@ -3164,6 +3170,9 @@ ZEND_VM_COLD_CONSTCONST_HANDLER(53, ZEND_FAST_CONCAT, CONST|TMPVAR|CV, CONST|TMP
|
||||||
|
zend_string_release_ex(op2_str, 0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
+ if (UNEXPECTED(ZSTR_LEN(op1_str) > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
+ }
|
||||||
|
str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str));
|
||||||
|
memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h
|
||||||
|
index 049d0f2126..eeca7ebb75 100644
|
||||||
|
--- a/Zend/zend_vm_execute.h
|
||||||
|
+++ b/Zend/zend_vm_execute.h
|
||||||
|
@@ -6348,6 +6348,9 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_
|
||||||
|
!ZSTR_IS_INTERNED(op1_str) && GC_REFCOUNT(op1_str) == 1) {
|
||||||
|
size_t len = ZSTR_LEN(op1_str);
|
||||||
|
|
||||||
|
+ if (UNEXPECTED(len > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
+ }
|
||||||
|
str = zend_string_extend(op1_str, len + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str) + len, ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
ZVAL_NEW_STR(EX_VAR(opline->result.var), str);
|
||||||
|
@@ -6355,6 +6358,9 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_
|
||||||
|
zend_string_release_ex(op2_str, 0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
+ if (UNEXPECTED(ZSTR_LEN(op1_str) > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
+ }
|
||||||
|
str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str));
|
||||||
|
memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
@@ -8225,7 +8231,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CONCAT_SPEC_CONST_TMPVAR_HANDL
|
||||||
|
size_t len = ZSTR_LEN(op1_str);
|
||||||
|
|
||||||
|
if (UNEXPECTED(len > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
- zend_error_noreturn(E_ERROR, "Integer overflow in memory allocation");
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
}
|
||||||
|
str = zend_string_extend(op1_str, len + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str) + len, ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
@@ -8234,6 +8240,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CONCAT_SPEC_CONST_TMPVAR_HANDL
|
||||||
|
zend_string_release_ex(op2_str, 0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
+ if (UNEXPECTED(ZSTR_LEN(op1_str) > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
+ }
|
||||||
|
str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str));
|
||||||
|
memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
@@ -8641,6 +8650,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CONST_TMPVAR_
|
||||||
|
!ZSTR_IS_INTERNED(op1_str) && GC_REFCOUNT(op1_str) == 1) {
|
||||||
|
size_t len = ZSTR_LEN(op1_str);
|
||||||
|
|
||||||
|
+ if (UNEXPECTED(len > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
+ }
|
||||||
|
str = zend_string_extend(op1_str, len + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str) + len, ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
ZVAL_NEW_STR(EX_VAR(opline->result.var), str);
|
||||||
|
@@ -8648,6 +8660,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CONST_TMPVAR_
|
||||||
|
zend_string_release_ex(op2_str, 0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
+ if (UNEXPECTED(ZSTR_LEN(op1_str) > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
+ }
|
||||||
|
str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str));
|
||||||
|
memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
@@ -10613,7 +10628,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CONCAT_SPEC_CONST_CV_HANDLER(Z
|
||||||
|
size_t len = ZSTR_LEN(op1_str);
|
||||||
|
|
||||||
|
if (UNEXPECTED(len > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
- zend_error_noreturn(E_ERROR, "Integer overflow in memory allocation");
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
}
|
||||||
|
str = zend_string_extend(op1_str, len + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str) + len, ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
@@ -10622,6 +10637,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CONCAT_SPEC_CONST_CV_HANDLER(Z
|
||||||
|
zend_string_release_ex(op2_str, 0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
+ if (UNEXPECTED(ZSTR_LEN(op1_str) > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
+ }
|
||||||
|
str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str));
|
||||||
|
memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
@@ -11029,6 +11047,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CONST_CV_HAND
|
||||||
|
!ZSTR_IS_INTERNED(op1_str) && GC_REFCOUNT(op1_str) == 1) {
|
||||||
|
size_t len = ZSTR_LEN(op1_str);
|
||||||
|
|
||||||
|
+ if (UNEXPECTED(len > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
+ }
|
||||||
|
str = zend_string_extend(op1_str, len + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str) + len, ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
ZVAL_NEW_STR(EX_VAR(opline->result.var), str);
|
||||||
|
@@ -11036,6 +11057,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CONST_CV_HAND
|
||||||
|
zend_string_release_ex(op2_str, 0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
+ if (UNEXPECTED(ZSTR_LEN(op1_str) > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
+ }
|
||||||
|
str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str));
|
||||||
|
memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
@@ -14644,7 +14668,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CONCAT_SPEC_TMPVAR_CONST_HANDL
|
||||||
|
size_t len = ZSTR_LEN(op1_str);
|
||||||
|
|
||||||
|
if (UNEXPECTED(len > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
- zend_error_noreturn(E_ERROR, "Integer overflow in memory allocation");
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
}
|
||||||
|
str = zend_string_extend(op1_str, len + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str) + len, ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
@@ -14653,6 +14677,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CONCAT_SPEC_TMPVAR_CONST_HANDL
|
||||||
|
zend_string_release_ex(op2_str, 0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
+ if (UNEXPECTED(ZSTR_LEN(op1_str) > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
+ }
|
||||||
|
str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str));
|
||||||
|
memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
@@ -15374,6 +15401,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_TMPVAR_CONST_
|
||||||
|
!ZSTR_IS_INTERNED(op1_str) && GC_REFCOUNT(op1_str) == 1) {
|
||||||
|
size_t len = ZSTR_LEN(op1_str);
|
||||||
|
|
||||||
|
+ if (UNEXPECTED(len > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
+ }
|
||||||
|
str = zend_string_extend(op1_str, len + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str) + len, ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
ZVAL_NEW_STR(EX_VAR(opline->result.var), str);
|
||||||
|
@@ -15381,6 +15411,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_TMPVAR_CONST_
|
||||||
|
zend_string_release_ex(op2_str, 0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
+ if (UNEXPECTED(ZSTR_LEN(op1_str) > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
+ }
|
||||||
|
str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str));
|
||||||
|
memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
@@ -16067,7 +16100,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CONCAT_SPEC_TMPVAR_TMPVAR_HAND
|
||||||
|
size_t len = ZSTR_LEN(op1_str);
|
||||||
|
|
||||||
|
if (UNEXPECTED(len > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
- zend_error_noreturn(E_ERROR, "Integer overflow in memory allocation");
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
}
|
||||||
|
str = zend_string_extend(op1_str, len + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str) + len, ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
@@ -16076,6 +16109,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CONCAT_SPEC_TMPVAR_TMPVAR_HAND
|
||||||
|
zend_string_release_ex(op2_str, 0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
+ if (UNEXPECTED(ZSTR_LEN(op1_str) > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
+ }
|
||||||
|
str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str));
|
||||||
|
memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
@@ -16797,6 +16833,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_TMPVAR_TMPVAR
|
||||||
|
!ZSTR_IS_INTERNED(op1_str) && GC_REFCOUNT(op1_str) == 1) {
|
||||||
|
size_t len = ZSTR_LEN(op1_str);
|
||||||
|
|
||||||
|
+ if (UNEXPECTED(len > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
+ }
|
||||||
|
str = zend_string_extend(op1_str, len + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str) + len, ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
ZVAL_NEW_STR(EX_VAR(opline->result.var), str);
|
||||||
|
@@ -16804,6 +16843,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_TMPVAR_TMPVAR
|
||||||
|
zend_string_release_ex(op2_str, 0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
+ if (UNEXPECTED(ZSTR_LEN(op1_str) > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
+ }
|
||||||
|
str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str));
|
||||||
|
memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
@@ -17744,7 +17786,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CONCAT_SPEC_TMPVAR_CV_HANDLER(
|
||||||
|
size_t len = ZSTR_LEN(op1_str);
|
||||||
|
|
||||||
|
if (UNEXPECTED(len > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
- zend_error_noreturn(E_ERROR, "Integer overflow in memory allocation");
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
}
|
||||||
|
str = zend_string_extend(op1_str, len + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str) + len, ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
@@ -17753,6 +17795,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CONCAT_SPEC_TMPVAR_CV_HANDLER(
|
||||||
|
zend_string_release_ex(op2_str, 0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
+ if (UNEXPECTED(ZSTR_LEN(op1_str) > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
+ }
|
||||||
|
str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str));
|
||||||
|
memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
@@ -18112,6 +18157,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_TMPVAR_CV_HAN
|
||||||
|
!ZSTR_IS_INTERNED(op1_str) && GC_REFCOUNT(op1_str) == 1) {
|
||||||
|
size_t len = ZSTR_LEN(op1_str);
|
||||||
|
|
||||||
|
+ if (UNEXPECTED(len > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
+ }
|
||||||
|
str = zend_string_extend(op1_str, len + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str) + len, ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
ZVAL_NEW_STR(EX_VAR(opline->result.var), str);
|
||||||
|
@@ -18119,6 +18167,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_TMPVAR_CV_HAN
|
||||||
|
zend_string_release_ex(op2_str, 0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
+ if (UNEXPECTED(ZSTR_LEN(op1_str) > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
+ }
|
||||||
|
str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str));
|
||||||
|
memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
@@ -39226,7 +39277,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CONCAT_SPEC_CV_CONST_HANDLER(Z
|
||||||
|
size_t len = ZSTR_LEN(op1_str);
|
||||||
|
|
||||||
|
if (UNEXPECTED(len > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
- zend_error_noreturn(E_ERROR, "Integer overflow in memory allocation");
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
}
|
||||||
|
str = zend_string_extend(op1_str, len + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str) + len, ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
@@ -39235,6 +39286,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CONCAT_SPEC_CV_CONST_HANDLER(Z
|
||||||
|
zend_string_release_ex(op2_str, 0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
+ if (UNEXPECTED(ZSTR_LEN(op1_str) > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
+ }
|
||||||
|
str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str));
|
||||||
|
memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
@@ -41677,6 +41731,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CV_CONST_HAND
|
||||||
|
!ZSTR_IS_INTERNED(op1_str) && GC_REFCOUNT(op1_str) == 1) {
|
||||||
|
size_t len = ZSTR_LEN(op1_str);
|
||||||
|
|
||||||
|
+ if (UNEXPECTED(len > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
+ }
|
||||||
|
str = zend_string_extend(op1_str, len + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str) + len, ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
ZVAL_NEW_STR(EX_VAR(opline->result.var), str);
|
||||||
|
@@ -41684,6 +41741,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CV_CONST_HAND
|
||||||
|
zend_string_release_ex(op2_str, 0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
+ if (UNEXPECTED(ZSTR_LEN(op1_str) > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
+ }
|
||||||
|
str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str));
|
||||||
|
memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
@@ -42951,7 +43011,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CONCAT_SPEC_CV_TMPVAR_HANDLER(
|
||||||
|
size_t len = ZSTR_LEN(op1_str);
|
||||||
|
|
||||||
|
if (UNEXPECTED(len > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
- zend_error_noreturn(E_ERROR, "Integer overflow in memory allocation");
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
}
|
||||||
|
str = zend_string_extend(op1_str, len + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str) + len, ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
@@ -42960,6 +43020,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CONCAT_SPEC_CV_TMPVAR_HANDLER(
|
||||||
|
zend_string_release_ex(op2_str, 0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
+ if (UNEXPECTED(ZSTR_LEN(op1_str) > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
+ }
|
||||||
|
str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str));
|
||||||
|
memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
@@ -45331,6 +45394,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CV_TMPVAR_HAN
|
||||||
|
!ZSTR_IS_INTERNED(op1_str) && GC_REFCOUNT(op1_str) == 1) {
|
||||||
|
size_t len = ZSTR_LEN(op1_str);
|
||||||
|
|
||||||
|
+ if (UNEXPECTED(len > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
+ }
|
||||||
|
str = zend_string_extend(op1_str, len + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str) + len, ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
ZVAL_NEW_STR(EX_VAR(opline->result.var), str);
|
||||||
|
@@ -45338,6 +45404,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CV_TMPVAR_HAN
|
||||||
|
zend_string_release_ex(op2_str, 0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
+ if (UNEXPECTED(ZSTR_LEN(op1_str) > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
+ }
|
||||||
|
str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str));
|
||||||
|
memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
@@ -48150,7 +48219,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CONCAT_SPEC_CV_CV_HANDLER(ZEND
|
||||||
|
size_t len = ZSTR_LEN(op1_str);
|
||||||
|
|
||||||
|
if (UNEXPECTED(len > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
- zend_error_noreturn(E_ERROR, "Integer overflow in memory allocation");
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
}
|
||||||
|
str = zend_string_extend(op1_str, len + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str) + len, ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
@@ -48159,6 +48228,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CONCAT_SPEC_CV_CV_HANDLER(ZEND
|
||||||
|
zend_string_release_ex(op2_str, 0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
+ if (UNEXPECTED(ZSTR_LEN(op1_str) > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
+ }
|
||||||
|
str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str));
|
||||||
|
memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
@@ -50629,6 +50701,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CV_CV_HANDLER
|
||||||
|
!ZSTR_IS_INTERNED(op1_str) && GC_REFCOUNT(op1_str) == 1) {
|
||||||
|
size_t len = ZSTR_LEN(op1_str);
|
||||||
|
|
||||||
|
+ if (UNEXPECTED(len > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
+ }
|
||||||
|
str = zend_string_extend(op1_str, len + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str) + len, ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
ZVAL_NEW_STR(EX_VAR(opline->result.var), str);
|
||||||
|
@@ -50636,6 +50711,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FAST_CONCAT_SPEC_CV_CV_HANDLER
|
||||||
|
zend_string_release_ex(op2_str, 0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
+ if (UNEXPECTED(ZSTR_LEN(op1_str) > ZSTR_MAX_LEN - ZSTR_LEN(op2_str))) {
|
||||||
|
+ zend_mm_safe_error_ex("Integer overflow in memory allocation");
|
||||||
|
+ }
|
||||||
|
str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0);
|
||||||
|
memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str));
|
||||||
|
memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
|
||||||
|
diff --git a/ext/session/session.c b/ext/session/session.c
|
||||||
|
index 3c875296c3..0c45b1bb41 100644
|
||||||
|
--- a/ext/session/session.c
|
||||||
|
+++ b/ext/session/session.c
|
||||||
|
@@ -3017,7 +3017,7 @@ static int php_session_rfc1867_callback(unsigned int event, void *event_data, vo
|
||||||
|
if (php_session_rfc1867_orig_callback) {
|
||||||
|
retval = php_session_rfc1867_orig_callback(event, event_data, extra);
|
||||||
|
}
|
||||||
|
- if (!PS(rfc1867_enabled)) {
|
||||||
|
+ if (!PS(rfc1867_enabled) || true) {
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/main/SAPI.c b/main/SAPI.c
|
||||||
|
index eea417cedc..85d964d21b 100644
|
||||||
|
--- a/main/SAPI.c
|
||||||
|
+++ b/main/SAPI.c
|
||||||
|
@@ -503,18 +503,23 @@ SAPI_API void sapi_deactivate_module(void)
|
||||||
|
}
|
||||||
|
if (SG(request_info).auth_user) {
|
||||||
|
efree(SG(request_info).auth_user);
|
||||||
|
+ SG(request_info).auth_user = NULL;
|
||||||
|
}
|
||||||
|
if (SG(request_info).auth_password) {
|
||||||
|
efree(SG(request_info).auth_password);
|
||||||
|
+ SG(request_info).auth_password = NULL;
|
||||||
|
}
|
||||||
|
if (SG(request_info).auth_digest) {
|
||||||
|
efree(SG(request_info).auth_digest);
|
||||||
|
+ SG(request_info).auth_digest = NULL;
|
||||||
|
}
|
||||||
|
if (SG(request_info).content_type_dup) {
|
||||||
|
efree(SG(request_info).content_type_dup);
|
||||||
|
+ SG(request_info).content_type_dup = NULL;
|
||||||
|
}
|
||||||
|
if (SG(request_info).current_user) {
|
||||||
|
efree(SG(request_info).current_user);
|
||||||
|
+ SG(request_info).current_user = NULL;
|
||||||
|
}
|
||||||
|
if (sapi_module.deactivate) {
|
||||||
|
sapi_module.deactivate();
|
||||||
|
diff --git a/main/main.c b/main/main.c
|
||||||
|
index c58ea58bf5..48feda4bc7 100644
|
||||||
|
--- a/main/main.c
|
||||||
|
+++ b/main/main.c
|
||||||
|
@@ -1847,6 +1847,8 @@ void php_request_shutdown(void *dummy)
|
||||||
|
|
||||||
|
for (i=0; i<NUM_TRACK_VARS; i++) {
|
||||||
|
zval_ptr_dtor(&PG(http_globals)[i]);
|
||||||
|
+ /* May be accessed before php_request_startup() */
|
||||||
|
+ ZVAL_UNDEF(&PG(http_globals)[i]);
|
||||||
|
}
|
||||||
|
} zend_end_try();
|
||||||
|
|
||||||
|
@@ -1878,6 +1880,7 @@ void php_request_shutdown(void *dummy)
|
||||||
|
|
||||||
|
/* 15. Free Willy (here be crashes) */
|
||||||
|
zend_interned_strings_deactivate();
|
||||||
|
+ clear_last_error();
|
||||||
|
zend_try {
|
||||||
|
shutdown_memory_manager(CG(unclean_shutdown) || !report_memleaks, 0);
|
||||||
|
} zend_end_try();
|
||||||
|
@@ -1901,6 +1904,9 @@ void php_request_shutdown(void *dummy)
|
||||||
|
#ifdef HAVE_DTRACE
|
||||||
|
DTRACE_REQUEST_SHUTDOWN(SAFE_FILENAME(SG(request_info).path_translated), SAFE_FILENAME(SG(request_info).request_uri), (char *)SAFE_FILENAME(SG(request_info).request_method));
|
||||||
|
#endif /* HAVE_DTRACE */
|
||||||
|
+
|
||||||
|
+ /* May be accessed before php_request_startup() */
|
||||||
|
+ PG(modules_activated) = 0;
|
||||||
|
}
|
||||||
|
/* }}} */
|
||||||
|
|
||||||
|
diff --git a/main/php_variables.c b/main/php_variables.c
|
||||||
|
index 27a9ad089e..b17673060a 100644
|
||||||
|
--- a/main/php_variables.c
|
||||||
|
+++ b/main/php_variables.c
|
||||||
|
@@ -213,7 +213,7 @@ PHPAPI void php_register_variable_ex(const char *var_name, zval *val, zval *trac
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!index) {
|
||||||
|
- array_init(&gpc_element);
|
||||||
|
+ array_init_singleton(&gpc_element);
|
||||||
|
if ((gpc_element_p = zend_hash_next_index_insert(symtable1, &gpc_element)) == NULL) {
|
||||||
|
zend_array_destroy(Z_ARR(gpc_element));
|
||||||
|
zval_ptr_dtor_nogc(val);
|
||||||
|
@@ -224,7 +224,7 @@ PHPAPI void php_register_variable_ex(const char *var_name, zval *val, zval *trac
|
||||||
|
gpc_element_p = zend_symtable_str_find(symtable1, index, index_len);
|
||||||
|
if (!gpc_element_p) {
|
||||||
|
zval tmp;
|
||||||
|
- array_init(&tmp);
|
||||||
|
+ array_init_singleton(&tmp);
|
||||||
|
gpc_element_p = zend_symtable_str_update_ind(symtable1, index, index_len, &tmp);
|
||||||
|
} else {
|
||||||
|
if (Z_TYPE_P(gpc_element_p) == IS_INDIRECT) {
|
||||||
|
@@ -232,7 +232,7 @@ PHPAPI void php_register_variable_ex(const char *var_name, zval *val, zval *trac
|
||||||
|
}
|
||||||
|
if (Z_TYPE_P(gpc_element_p) != IS_ARRAY) {
|
||||||
|
zval_ptr_dtor_nogc(gpc_element_p);
|
||||||
|
- array_init(gpc_element_p);
|
||||||
|
+ array_init_singleton(gpc_element_p);
|
||||||
|
} else {
|
||||||
|
SEPARATE_ARRAY(gpc_element_p);
|
||||||
|
}
|
||||||
|
@@ -424,7 +424,7 @@ SAPI_API SAPI_TREAT_DATA_FUNC(php_default_treat_data)
|
||||||
|
case PARSE_POST:
|
||||||
|
case PARSE_GET:
|
||||||
|
case PARSE_COOKIE:
|
||||||
|
- array_init(&array);
|
||||||
|
+ array_init_singleton(&array);
|
||||||
|
switch (arg) {
|
||||||
|
case PARSE_POST:
|
||||||
|
zval_ptr_dtor_nogc(&PG(http_globals)[TRACK_VARS_POST]);
|
||||||
|
diff --git a/main/rfc1867.c b/main/rfc1867.c
|
||||||
|
index 3086e8da3d..b64574505d 100644
|
||||||
|
--- a/main/rfc1867.c
|
||||||
|
+++ b/main/rfc1867.c
|
||||||
|
@@ -390,6 +390,14 @@ static int find_boundary(multipart_buffer *self, char *boundary)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
+static zend_bool php_mime_should_save_hdr(const char *name)
|
||||||
|
+{
|
||||||
|
+ return !strcasecmp(name, "Content-Disposition")
|
||||||
|
+ || !strcasecmp(name, "Content-Type");
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static char *php_mime_get_hdr_value(zend_llist header, char *key);
|
||||||
|
+
|
||||||
|
/* parse headers */
|
||||||
|
static int multipart_buffer_headers(multipart_buffer *self, zend_llist *header)
|
||||||
|
{
|
||||||
|
@@ -430,10 +438,16 @@ static int multipart_buffer_headers(multipart_buffer *self, zend_llist *header)
|
||||||
|
}
|
||||||
|
|
||||||
|
*value = '\0';
|
||||||
|
- do { value++; } while (isspace(*value));
|
||||||
|
|
||||||
|
- key = estrdup(line);
|
||||||
|
- smart_string_appends(&buf_value, value);
|
||||||
|
+ /* Keep only headers we use, and ignore duplicates */
|
||||||
|
+ if (!php_mime_should_save_hdr(line)
|
||||||
|
+ || php_mime_get_hdr_value(*header, line)) {
|
||||||
|
+ key = NULL;
|
||||||
|
+ } else {
|
||||||
|
+ key = estrdup(line);
|
||||||
|
+ do { value++; } while (isspace((unsigned char)*value));
|
||||||
|
+ smart_string_appends(&buf_value, value);
|
||||||
|
+ }
|
||||||
|
} else if (buf_value.c) { /* If no ':' on the line, add to previous line */
|
||||||
|
smart_string_appends(&buf_value, line);
|
||||||
|
} else {
|
||||||
|
@@ -507,11 +521,11 @@ static char *php_ap_getword(const zend_encoding *encoding, char **line, char sto
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
-static char *substring_conf(char *start, int len, char quote)
|
||||||
|
+static char *substring_conf(char *start, size_t len, char quote)
|
||||||
|
{
|
||||||
|
char *result = emalloc(len + 1);
|
||||||
|
char *resp = result;
|
||||||
|
- int i;
|
||||||
|
+ size_t i;
|
||||||
|
|
||||||
|
for (i = 0; i < len && start[i] != quote; ++i) {
|
||||||
|
if (start[i] == '\\' && (start[i + 1] == '\\' || (quote && start[i + 1] == quote))) {
|
||||||
|
@@ -539,14 +553,14 @@ static char *php_ap_getword_conf(const zend_encoding *encoding, char *str)
|
||||||
|
char quote = *str;
|
||||||
|
|
||||||
|
str++;
|
||||||
|
- return substring_conf(str, (int)strlen(str), quote);
|
||||||
|
+ return substring_conf(str, strlen(str), quote);
|
||||||
|
} else {
|
||||||
|
char *strend = str;
|
||||||
|
|
||||||
|
while (*strend && !isspace(*strend)) {
|
||||||
|
++strend;
|
||||||
|
}
|
||||||
|
- return substring_conf(str, strend - str, 0);
|
||||||
|
+ return substring_conf(str, (size_t)(strend - str), 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
# Generated-file counterpart of the ext/pdo/pdo_sql_parser.re and
|
||||||
|
# ext/standard/url_scanner_ex.re hunks of php-8.0.30-sury-25.patch
|
||||||
|
# (so the fixes are built without re2c). Apply with -p1 after sury-25.
|
||||||
|
diff -ru a/ext/pdo/pdo_sql_parser.c b/ext/pdo/pdo_sql_parser.c
|
||||||
|
--- a/ext/pdo/pdo_sql_parser.c 2026-11-20 13:56:18.039743547 +0100
|
||||||
|
+++ b/ext/pdo/pdo_sql_parser.c 2026-11-20 13:56:18.043743569 +0100
|
||||||
|
@@ -397,7 +397,7 @@
|
||||||
|
|
||||||
|
if (t == PDO_PARSER_BIND) {
|
||||||
|
ptrdiff_t len = s.cur - s.tok;
|
||||||
|
- if ((inquery < (s.cur - len)) && isalnum(*(s.cur - len - 1))) {
|
||||||
|
+ if ((inquery < (s.cur - len)) && isalnum((unsigned char)s.cur[-len - 1])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
query_type |= PDO_PLACEHOLDER_NAMED;
|
||||||
|
diff -ru a/ext/standard/url_scanner_ex.c b/ext/standard/url_scanner_ex.c
|
||||||
|
--- a/ext/standard/url_scanner_ex.c 2026-11-20 13:56:18.047743589 +0100
|
||||||
|
+++ b/ext/standard/url_scanner_ex.c 2026-11-20 13:56:18.051743612 +0100
|
||||||
|
@@ -86,7 +86,7 @@
|
||||||
|
|
||||||
|
*val++ = '\0';
|
||||||
|
for (q = key; *q; q++) {
|
||||||
|
- *q = tolower(*q);
|
||||||
|
+ *q = tolower((unsigned char)*q);
|
||||||
|
}
|
||||||
|
keylen = q - key;
|
||||||
|
str = zend_string_init(key, keylen, 1);
|
||||||
|
@@ -135,7 +135,7 @@
|
||||||
|
char *q;
|
||||||
|
|
||||||
|
for (q = key; *q; q++) {
|
||||||
|
- *q = tolower(*q);
|
||||||
|
+ *q = tolower((unsigned char)*q);
|
||||||
|
}
|
||||||
|
keylen = q - key;
|
||||||
|
if (keylen > 0) {
|
||||||
|
@@ -449,7 +449,7 @@
|
||||||
|
}
|
||||||
|
smart_str_appendl(&ctx->tag, start, YYCURSOR - start);
|
||||||
|
for (i = 0; i < ZSTR_LEN(ctx->tag.s); i++)
|
||||||
|
- ZSTR_VAL(ctx->tag.s)[i] = tolower((int)(unsigned char)ZSTR_VAL(ctx->tag.s)[i]);
|
||||||
|
+ ZSTR_VAL(ctx->tag.s)[i] = tolower((unsigned char)ZSTR_VAL(ctx->tag.s)[i]);
|
||||||
|
/* intentionally using str_find here, in case the hash value is set, but the string val is changed later */
|
||||||
|
if ((ctx->lookup_data = zend_hash_str_find_ptr(ctx->tags, ZSTR_VAL(ctx->tag.s), ZSTR_LEN(ctx->tag.s))) != NULL) {
|
||||||
|
ok = 1;
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,71 @@
|
|||||||
|
diff --git a/ext/mysqli/tests/mysqlnd_row_decode_failure_refetch.phpt b/ext/mysqli/tests/mysqlnd_row_decode_failure_refetch.phpt
|
||||||
|
new file mode 100644
|
||||||
|
index 00000000..12ce0b0b
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/ext/mysqli/tests/mysqlnd_row_decode_failure_refetch.phpt
|
||||||
|
@@ -0,0 +1,34 @@
|
||||||
|
+--TEST--
|
||||||
|
+mysqlnd: a row whose decoding failed is decoded again, never served from freed fields
|
||||||
|
+--EXTENSIONS--
|
||||||
|
+mysqli
|
||||||
|
+--FILE--
|
||||||
|
+<?php
|
||||||
|
+require_once 'fake_server.inc';
|
||||||
|
+
|
||||||
|
+$port = 33305;
|
||||||
|
+$process = run_fake_server_in_background('stmt_response_row_over_read_int', $port);
|
||||||
|
+$process->wait();
|
||||||
|
+
|
||||||
|
+$conn = new mysqli("127.0.0.1", "root", "", "", $port);
|
||||||
|
+$stmt = $conn->prepare("SELECT strval, intval FROM data");
|
||||||
|
+$stmt->execute();
|
||||||
|
+$result = $stmt->get_result();
|
||||||
|
+
|
||||||
|
+$first = @$result->fetch_assoc();
|
||||||
|
+var_dump($first);
|
||||||
|
+$result->data_seek(0);
|
||||||
|
+$second = @$result->fetch_assoc();
|
||||||
|
+var_dump($second);
|
||||||
|
+
|
||||||
|
+$result->free();
|
||||||
|
+$stmt->close();
|
||||||
|
+$conn->close();
|
||||||
|
+$process->terminate(true);
|
||||||
|
+print "done!";
|
||||||
|
+?>
|
||||||
|
+--EXPECTF--
|
||||||
|
+%A
|
||||||
|
+bool(false)
|
||||||
|
+bool(false)
|
||||||
|
+%Adone!%A
|
||||||
|
diff --git a/ext/mysqlnd/mysqlnd_wireprotocol.c b/ext/mysqlnd/mysqlnd_wireprotocol.c
|
||||||
|
index 23a3cb8b..316b276e 100644
|
||||||
|
--- a/ext/mysqlnd/mysqlnd_wireprotocol.c
|
||||||
|
+++ b/ext/mysqlnd/mysqlnd_wireprotocol.c
|
||||||
|
@@ -1594,6 +1594,8 @@ php_mysqlnd_rowp_read_binary_protocol(MYSQLND_ROW_BUFFER * row_buffer, zval * fi
|
||||||
|
if (rbs <= row_position) {
|
||||||
|
for (j = 0, current_field = start_field; j < i; current_field++, j++) {
|
||||||
|
zval_ptr_dtor(current_field);
|
||||||
|
+ /* the caller keeps this array and frees it again later */
|
||||||
|
+ ZVAL_UNDEF(current_field);
|
||||||
|
}
|
||||||
|
php_error_docref(NULL, E_WARNING, "Malformed server packet. No packet space left for the field");
|
||||||
|
DBG_RETURN(FAIL);
|
||||||
|
@@ -1602,6 +1604,8 @@ php_mysqlnd_rowp_read_binary_protocol(MYSQLND_ROW_BUFFER * row_buffer, zval * fi
|
||||||
|
if (p == NULL) {
|
||||||
|
for (j = 0, current_field = start_field; j < i; current_field++, j++) {
|
||||||
|
zval_ptr_dtor(current_field);
|
||||||
|
+ /* the caller keeps this array and frees it again later */
|
||||||
|
+ ZVAL_UNDEF(current_field);
|
||||||
|
}
|
||||||
|
DBG_RETURN(FAIL);
|
||||||
|
}
|
||||||
|
@@ -1686,6 +1690,8 @@ php_mysqlnd_rowp_read_text_protocol_aux(MYSQLND_ROW_BUFFER * row_buffer, zval *
|
||||||
|
php_error_docref(NULL, E_WARNING, "Malformed server packet. Field length pointing after end of packet");
|
||||||
|
for (j = 0, current_field = start_field; j < i; current_field++, j++) {
|
||||||
|
zval_ptr_dtor(current_field);
|
||||||
|
+ /* the caller keeps this array and frees it again later */
|
||||||
|
+ ZVAL_UNDEF(current_field);
|
||||||
|
}
|
||||||
|
DBG_RETURN(FAIL);
|
||||||
|
} else {
|
||||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user