Commit Graph

1172 Commits

Author SHA1 Message Date
Dmitry Stogov
a56bba14e0 Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0:
  Prevent modification of immutable arrays (ext/mbstring/tests/bug26639.phpt failure with opcache.protect_memory=1)
2016-11-17 13:34:32 +03:00
Dmitry Stogov
a67637039f Prevent modification of immutable arrays (ext/mbstring/tests/bug26639.phpt failure with opcache.protect_memory=1) 2016-11-17 13:33:05 +03:00
Xinchen Hui
229024c725 Fixed bug #73532 (Null pointer dereference in mb_eregi) 2016-11-16 15:05:04 +08:00
Yasuo Ohgaki
1ecf361c15 Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0:
  Fix Bug #72992 mbstring.internal_encoding doesn't inherit default_charset
2016-09-08 13:32:47 +09:00
Yasuo Ohgaki
379d9a1cfc Merge branch 'PHP-5.6' into PHP-7.0
* PHP-5.6:
  Fix Bug #72992 mbstring.internal_encoding doesn't inherit default_charset
2016-09-08 13:32:31 +09:00
Yasuo Ohgaki
8bbd0952e5 Fix Bug #72992 mbstring.internal_encoding doesn't inherit default_charset 2016-09-08 13:17:10 +09:00
Christoph M. Becker
68d3501381 Merge branch 'pull-request/2115' into PHP-7.1 2016-09-06 14:14:23 +02:00
Yasuo Ohgaki
012232b9a4 Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0:
  Fixed Bug #66964 mb_convert_variables() cannot detect recursion
2016-09-06 16:42:07 +09:00
Yasuo Ohgaki
6f1a52bfbb Merge branch 'PHP-5.6' into PHP-7.0
* PHP-5.6:
  Fixed Bug #66964 mb_convert_variables() cannot detect recursion
2016-09-06 16:41:52 +09:00
Yasuo Ohgaki
a25f6f89cd Fixed Bug #66964 mb_convert_variables() cannot detect recursion 2016-09-06 16:05:34 +09:00
Stanislav Malyshev
3bfd06061e Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0:
  Sync fix for bug #72910 with current upstream
2016-09-04 19:15:45 -07:00
Stanislav Malyshev
c3dfe57c23 Merge branch 'PHP-5.6' into PHP-7.0
* PHP-5.6:
  Sync fix for bug #72910 with current upstream
2016-09-04 19:15:30 -07:00
Stanislav Malyshev
d1fbc98ff6 Sync fix for bug #72910 with current upstream 2016-09-04 19:13:48 -07:00
Christoph M. Becker
94b66b8793 Merge branch 'PHP-7.0' into PHP-7.1 2016-09-04 16:47:55 +02:00
Christoph M. Becker
7f97d63130 Merge branch 'PHP-5.6' into PHP-7.0 2016-09-04 16:39:45 +02:00
Christoph M. Becker
b7259b71b4 Fix #72994: mbc_to_code() out of bounds read
We're backporting commit 999a3553 to the still supported PHP 5.6.
2016-09-04 16:37:06 +02:00
Christoph M. Becker
727b422ad9 Fix #72948: Uncatchable "Catchable" fatal error for class to string conversions
E_RECOVERABLE errors are reported as "Catchable fatal error". This is
misleading, because they actually can't be caught via try-catch statements.
Therefore we change the wording to "Recoverable fatal error" as suggested by
Nikita.
2016-09-03 13:05:37 +02:00
Stanislav Malyshev
01f4a52aaa Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0:
  Fix bug #72910
  5.6.27 will be next
2016-09-01 23:29:17 -07:00
Stanislav Malyshev
ccc8d92d3d Merge branch 'PHP-5.6' into PHP-7.0
* PHP-5.6:
  Fix bug #72910
  5.6.27 will be next
2016-09-01 23:28:44 -07:00
Stanislav Malyshev
e576714f6b Fix bug #72910
Merge upstream patch from 65bdf2a0d1
2016-09-01 23:27:06 -07:00
Christoph M. Becker
ecdef60d00 Merge branch 'PHP-7.0' into PHP-7.1 2016-08-30 15:12:49 +02:00
Christoph M. Becker
972302d2f0 Merge branch 'PHP-5.6' into PHP-7.0 2016-08-30 15:01:12 +02:00
Christoph M. Becker
2f10db36af Fix #66797: mb_substr only takes 32-bit signed integer
`from` and `len` are `long`, but get passed to mbfl_substr() which expects
`int`s. Therefore we clamp the values to avoid the undefined conversion
behavior.
2016-08-30 14:52:47 +02:00
ju1ius
03d03243fa Fix #72711: mb_ereg does not clear the $regs parameter on failure
When `mb_ereg` failed to match, it didn't update the `$regs` argument.
Now it will always set it to the empty array.
2016-08-05 13:22:10 +02:00
Christoph M. Becker
9c2814313d Merge branch 'PHP-7.0' into PHP-7.1 2016-07-30 12:04:12 +02:00
Christoph M. Becker
e5940aa795 Merge branch 'PHP-5.6' into PHP-7.0 2016-07-30 12:01:29 +02:00
ju1ius
1d32b80903 fixes bad address given to onig_error_code_to_str
Closes bug #72710

(cherry picked from commit 0fb7eb6723)
2016-07-30 11:46:34 +02:00
Christoph M. Becker
de755310b4 Merge branch 'PHP-7.0' into PHP-7.1
# Resolved conflicts:
#	ext/mbstring/php_mbregex.c
2016-07-28 15:50:41 +02:00
Christoph M. Becker
805dc0ea47 Merge branch 'PHP-5.6' into PHP-7.0
# Resolved conflicts:
#	ext/mbstring/php_mbregex.c
2016-07-28 15:26:29 +02:00
Christoph M. Becker
ee6900c3de Fix #72694: mb_ereg_search_setpos does not accept a string's last position
Setting the search position immediately behind the last character should be
allowed, so we fix this off-by-one error.
2016-07-28 15:21:48 +02:00
Christoph M. Becker
6aaef1ed34 Merge branch 'PHP-7.0' into PHP-7.1 2016-07-28 14:09:29 +02:00
Christoph M. Becker
a621023168 Merge branch 'PHP-5.6' into PHP-7.0 2016-07-28 14:03:40 +02:00
Christoph M. Becker
56cdaecb28 Fix #72693: mb_ereg_search increments search position when a match zero-width
That's caused by an off-by-one error, which we fix.
2016-07-28 13:57:38 +02:00
Christoph M. Becker
db69ea32cb Merge branch 'PHP-7.0' into PHP-7.1 2016-07-28 13:19:15 +02:00
Christoph M. Becker
18a37eeeec Merge branch 'PHP-5.6' into PHP-7.0
# Resolved conflicts:
#	ext/mbstring/php_mbregex.c
2016-07-28 13:12:40 +02:00
Christoph M. Becker
d276e6a838 Fix #72691: mb_ereg_search raises a warning if a match zero-width
That warning doesn't make sense (PCRE doesn't throw such a warning either),
so we remove it.
2016-07-28 13:07:05 +02:00
Masaki Kagaya
69f468239b add test 2016-07-17 14:19:45 +02:00
Masaki Kagaya
eb3e7f7c10 check the encoding of argument for mb_ereg, mb_ereg_replace, mb_ereg_search_init 2016-07-17 14:19:45 +02:00
Masaki Kagaya
ee6ccea3eb add php_mb_check_encoding 2016-07-17 14:19:45 +02:00
Christoph M. Becker
0c98f51c84 Implement RFC "Deprecate mb_ereg_replace eval option"
<https://wiki.php.net/rfc/deprecate_mb_ereg_replace_eval_option> has been
accepted, so we implement it.
2016-07-11 11:20:01 +02:00
Aaron Piotrowski
24237027bc Merge branch 'throw-error-in-extensions' 2016-07-05 02:08:39 -05:00
Dmitry Stogov
323b2733f6 Fixed compilation warnings 2016-06-22 00:40:50 +03:00
Dmitry Stogov
1616038698 Added ZEND_ATTRIBUTE_FORMAT to some middind functions.
"%p" replaced by ZEND_LONG_FMT to avoid compilation warnings.
Fixed most incorrect use cases of format specifiers.
2016-06-21 16:00:37 +03:00
Stanislav Malyshev
3e0397c25c Merge branch 'PHP-7.0'
* PHP-7.0:
  iFixed bug #72446 - Integer Overflow in gdImagePaletteToTrueColor() resulting in heap overflow
  update NEWS
  fix tests
  fix build
  Fix bug #72455:  Heap Overflow due to integer overflows
  Fix bug #72434: ZipArchive class Use After Free Vulnerability in PHP's GC algorithm and unserialize
  Fixed ##72433: Use After Free Vulnerability in PHP's GC algorithm and unserialize
  Fix bug #72407: NULL Pointer Dereference at _gdScaleVert
  Fix bug #72402: _php_mb_regex_ereg_replace_exec - double free
  Fix bug #72298	pass2_no_dither out-of-bounds access
  Fixed #72339 Integer Overflow in _gd2GetHeader() resulting in heap overflow
  Fix bug #72262 - do not overflow int
  Fix bug #72400 and #72403 - prevent signed int overflows for string lengths
  Fix bug #72275: don't allow smart_str to overflow int
  Fix bug #72340: Double Free Courruption in wddx_deserialize
  Fix bug #72321 - use efree() for emalloc allocation
  5.6.23RC1
  fix NEWS
  set versions
2016-06-21 00:27:01 -07:00
Stanislav Malyshev
8705254f2d Merge branch 'PHP-7.0.8' into PHP-7.0
* PHP-7.0.8:
  iFixed bug #72446 - Integer Overflow in gdImagePaletteToTrueColor() resulting in heap overflow
  update NEWS
  fix tests
  fix build
  Fix bug #72455:  Heap Overflow due to integer overflows
  Fix bug #72434: ZipArchive class Use After Free Vulnerability in PHP's GC algorithm and unserialize
  Fixed ##72433: Use After Free Vulnerability in PHP's GC algorithm and unserialize
  Fix bug #72407: NULL Pointer Dereference at _gdScaleVert
  Fix bug #72402: _php_mb_regex_ereg_replace_exec - double free
  Fix bug #72298	pass2_no_dither out-of-bounds access
  Fixed #72339 Integer Overflow in _gd2GetHeader() resulting in heap overflow
  Fix bug #72262 - do not overflow int
  Fix bug #72400 and #72403 - prevent signed int overflows for string lengths
  Fix bug #72275: don't allow smart_str to overflow int
  Fix bug #72340: Double Free Courruption in wddx_deserialize
  Fix bug #72321 - use efree() for emalloc allocation
  5.6.23RC1
  fix NEWS
  set versions

Conflicts:
	configure.in
	main/php_version.h
2016-06-21 00:25:49 -07:00
Stanislav Malyshev
2a65544f78 Merge branch 'PHP-5.6.23' into PHP-7.0.8
* PHP-5.6.23: (24 commits)
  iFixed bug #72446 - Integer Overflow in gdImagePaletteToTrueColor() resulting in heap overflow
  update NEWS
  fix tests
  fix build
  Fix bug #72455:  Heap Overflow due to integer overflows
  Fix bug #72434: ZipArchive class Use After Free Vulnerability in PHP's GC algorithm and unserialize
  Fixed ##72433: Use After Free Vulnerability in PHP's GC algorithm and unserialize
  Fix bug #72407: NULL Pointer Dereference at _gdScaleVert
  Fix bug #72402: _php_mb_regex_ereg_replace_exec - double free
  Fix bug #72298	pass2_no_dither out-of-bounds access
  Fixed #72339 Integer Overflow in _gd2GetHeader() resulting in heap overflow
  Fix bug #72262 - do not overflow int
  Fix bug #72400 and #72403 - prevent signed int overflows for string lengths
  Fix bug #72275: don't allow smart_str to overflow int
  Fix bug #72340: Double Free Courruption in wddx_deserialize
  update NEWS
  Fix #66387: Stack overflow with imagefilltoborder
  Fix bug #72321 - use efree() for emalloc allocation
  5.6.23RC1
  Fix bug #72140 (segfault after calling ERR_free_strings())
  ...

Conflicts:
	configure.in
	ext/mbstring/php_mbregex.c
	ext/mcrypt/mcrypt.c
	ext/spl/spl_array.c
	ext/spl/spl_directory.c
	ext/standard/php_smart_str.h
	ext/standard/string.c
	ext/standard/url.c
	ext/wddx/wddx.c
	ext/zip/php_zip.c
	main/php_version.h
2016-06-21 00:24:32 -07:00
Stanislav Malyshev
7dde353ee7 Merge branch 'PHP-5.5' into PHP-5.6.23
* PHP-5.5:
  Fixed bug #72446 - Integer Overflow in gdImagePaletteToTrueColor() resulting in heap overflow
  update NEWS
  fix tests
  fix build
  Fix bug #72455:  Heap Overflow due to integer overflows
  Fix bug #72434: ZipArchive class Use After Free Vulnerability in PHP's GC algorithm and unserialize
  Fixed ##72433: Use After Free Vulnerability in PHP's GC algorithm and unserialize
  Fix bug #72407: NULL Pointer Dereference at _gdScaleVert
  Fix bug #72402: _php_mb_regex_ereg_replace_exec - double free
  Fix bug #72298	pass2_no_dither out-of-bounds access
  Fixed #72339 Integer Overflow in _gd2GetHeader() resulting in heap overflow
  Fix bug #72262 - do not overflow int
  Fix bug #72400 and #72403 - prevent signed int overflows for string lengths
  Fix bug #72275: don't allow smart_str to overflow int
  Fix bug #72340: Double Free Courruption in wddx_deserialize
  update NEWS
  Fix #66387: Stack overflow with imagefilltoborder
  Skip test which is 64bits only
  5.5.37 now

Conflicts:
	configure.in
	ext/mcrypt/mcrypt.c
	ext/spl/spl_directory.c
	main/php_version.h
2016-06-21 00:01:48 -07:00
Anatol Belski
3d3f11ede4 Fixed the UTF-8 and long path support in the streams on Windows.
Since long the default PHP charset is UTF-8, however the Windows part is
out of step with this important point. The current implementation in PHP
doesn't technically permit to handle UTF-8 filepath and several other
things. Till now, only the ANSI compatible APIs are being used. Here is more
about it

https://msdn.microsoft.com/en-us/library/windows/desktop/dd317752%28v=vs.85%29.aspx

The patch fixes not only issues with multibyte filenames under
incompatible codepages, but indirectly also issues with some other multibyte
encodings like BIG5, Shift-JIS, etc. by providing a clean way to access
filenames in UTF-8. Below is a small list of issues from the bug tracker,
that are getting fixed:

https://bugs.php.net/63401
https://bugs.php.net/41199
https://bugs.php.net/50203
https://bugs.php.net/71509
https://bugs.php.net/64699
https://bugs.php.net/64506
https://bugs.php.net/30195
https://bugs.php.net/65358
https://bugs.php.net/61315
https://bugs.php.net/70943
https://bugs.php.net/70903
https://bugs.php.net/63593
https://bugs.php.net/54977
https://bugs.php.net/54028
https://bugs.php.net/43148
https://bugs.php.net/30730
https://bugs.php.net/33350
https://bugs.php.net/35300
https://bugs.php.net/46990
https://bugs.php.net/61309
https://bugs.php.net/69333
https://bugs.php.net/45517
https://bugs.php.net/70551
https://bugs.php.net/50197
https://bugs.php.net/72200
https://bugs.php.net/37672

Yet more related tickets can for sure be found - on bugs.php.net, Stackoverflow
and Github. Some of the bugs are pretty recent, some descend to early
2000th, but  the user comments in there last even till today. Just for example,
bug #30195 was opened in 2004, the latest comment in there was made in 2014. It
is certain, that these bugs descend not only to pure PHP use cases, but get also
redirected from the popular PHP based projects. Given the modern systems (and
those supported by PHP) are always based on NTFS, there is no excuse to keep
these issues unresolved.

The internalization approach on Windows is in many ways different from
UNIX and Linux, while it supports and is based on Unicode. It depends on the
current system code page, APIs used and exact kind how the binary was compiled
The locale doesn't affect the way Unicode or ANSI API work. PHP in particular
is being compiled without _UNICODE defined and this is conditioned by the
way we handle strings. Here is more about it

https://msdn.microsoft.com/en-us/library/tsbaswba.aspx

However, with any system code page ANSI functions automatically convert
paths to UTF-16. Paths in some encodings incompatible with the
current system code page, won't work correctly with ANSI APIs. PHP
till now only uses the ANSI Windows APIs.

For example, on a system with the current code page 1252, the paths
in cp1252 are supported and transparently converted to UTF-16 by the
ANSI functions. Once one wants to handle a filepath encoded with cp932 on
that particular system, an ANSI or a POSIX compatible function used in
PHP will produce an erroneous result. When trying to convert that cp932 path
to UTF-8 and passing to the ANSI functions, an ANSI function would
likely interpret the UTF-8 string as some string in the current code page and
create a filepath that represents every single byte of the UTF-8 string.
These behaviors are not only broken but also disregard the documented
INI settings.

This patch solves the issies with the multibyte paths on Windows by
intelligently enforcing the usage of the Unicode aware APIs. For
functions expect Unicode (fe CreateFileW, FindFirstFileW, etc.), arguments
will be converted to UTF-16 wide chars. For functions returning Unicode
aware data (fe GetCurrentDirectoryW, etc.), resulting wide string is
converted back to char's depending on the current PHP charset settings,
either to the current ANSI codepage (this is the behavior prior to this patch)
or to UTF-8 (the default behavior).

In a particular case, users might have to explicitly set
internal_encoding or default_charset, if filenames in ANSI codepage are
necessary. Current tests show no regressions and witness that this will be an
exotic case, the current default UTF-8 encoding is compatible with any
supported system. The dependency libraries are long switching to Unicode APIs,
so some tests were also added for extensions not directly related to streams.
At large, the patch brings over 150 related tests into the core. Those target
and was run on various environments with European, Asian, etc. codepages.
General PHP frameworks was tested and showed no regressions.

The impact on the current C code base is low, the most places affected
are the Windows only places in the three files tsrm_win32.c, zend_virtual_cwd.c
and plain_wrapper.c. The actual implementation of the most of the wide
char supporting functionality is in win32/ioutil.* and win32/codepage.*,
several  low level functionsare extended in place to avoid reimplementation for
now. No performance impact was sighted. As previously mentioned, the ANSI APIs
used prior the patch perform Unicode conversions internally. Using the
Unicode  APIs directly while doing custom conversions just retains the status
quo. The ways to optimize it are open (fe. by implementing caching for the
strings converted to wide variants).

The long path implementation is user transparent. If a path exceeds the
length of _MAX_PATH, it'll be automatically prefixed with \\?\. The MAXPATHLEN
is set to 2048 bytes.

Appreciation to Pierre Joye, Matt Ficken, @algo13 and others for tips, ideas
and testing.

Thanks.
2016-06-20 12:45:39 +02:00
Stanislav Malyshev
5b597a2e5b Fix bug #72402: _php_mb_regex_ereg_replace_exec - double free 2016-06-18 21:48:39 -07:00
Xinchen Hui
85fd260916 Merge branch 'PHP-7.0'
* PHP-7.0:
  Fixed(attempt to) bug #72405 (mb_ereg_replace - mbc_to_code (oniguruma) - oob read access)
2016-06-15 14:55:43 +08:00