1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 08:12:21 +01:00

Fix #76510: file_exists() stopped working for phar://

We work around a strlen() optimization bug in GCC 8[1] by checking
whether the used GCC exhibits the broken behavior, and if so by
disabling `optimize-strlen`.

[1] <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86914>
This commit is contained in:
Christoph M. Becker
2018-09-11 12:23:20 +02:00
parent 1bb29a4af2
commit b117feeb2b
3 changed files with 40 additions and 0 deletions

1
NEWS
View File

@@ -5,6 +5,7 @@ PHP NEWS
- Core:
. Fixed bug #76825 (Undefined symbols ___cpuid_count). (Laruence)
. Fixed bug #76820 (Z_COPYABLE invalid definition). (mvdwerve, cmb)
. Fixed bug #76510 (file_exists() stopped working for phar://). (cmb)
- intl:
. Fixed bug #76829 (Incorrect validation of domain on idn_to_utf8()

View File

@@ -1739,6 +1739,42 @@ choke me
fi
])
dnl
dnl PHP_BROKEN_GCC_STRLEN_OPT
dnl
dnl Early releases of GCC 8 shipped with a strlen() optimization bug, so they
dnl didn't properly handle the `char val[1]` struct hack. See bug #76510.
dnl
AC_DEFUN([PHP_BROKEN_GCC_STRLEN_OPT], [
AC_CACHE_CHECK([for broken gcc optimize-strlen],ac_cv_have_broken_gcc_strlen_opt,[
AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
struct s
{
int i;
char c[1];
};
int main()
{
struct s *s = malloc(sizeof(struct s) + 3);
s->i = 3;
strcpy(s->c, "foo");
return strlen(s->c+1) == 2;
}
]])],[
ac_cv_have_broken_gcc_strlen_opt=yes
],[
ac_cv_have_broken_gcc_strlen_opt=no
],[
ac_cv_have_broken_gcc_strlen_opt=no
])])
if test "$ac_cv_have_broken_gcc_strlen_opt" = "yes"; then
CFLAGS="$CFLAGS -fno-optimize-strlen"
fi
])
dnl
dnl PHP_FOPENCOOKIE
dnl

View File

@@ -503,6 +503,9 @@ immintrin.h
PHP_FOPENCOOKIE
PHP_BROKEN_GETCWD
PHP_BROKEN_GLIBC_FOPEN_APPEND
if test "$GCC" = "yes"; then
PHP_BROKEN_GCC_STRLEN_OPT
fi
dnl Checks for typedefs, structures, and compiler characteristics.
dnl -------------------------------------------------------------------------