Commit Graph

619 Commits

Author SHA1 Message Date
Anatol Belski
7360e6a36f Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0:
  Revert "Add more constants, improve comments, and add tests"
2017-07-10 17:01:25 +02:00
Anatol Belski
a797421e98 Revert "Add more constants, improve comments, and add tests"
This reverts commit 0c4f11ecaa.
2017-07-10 16:53:56 +02:00
Bob Weinand
44d734254a Merge branch 'PHP-7.0' into PHP-7.1 2017-06-25 20:13:48 +02:00
Matthew Trescott
0c4f11ecaa Add more constants, improve comments, and add tests 2017-06-25 20:12:45 +02:00
Nikita Popov
bda0f4e8dc Merge branch 'PHP-7.0' into PHP-7.1 2017-06-25 15:30:29 +02:00
wapmorgan
cd1869bcf2 Remove invalid check of dictionary content and add initialization of dictionary if raw compression used 2017-06-25 10:53:28 +02:00
Anatol Belski
f3c4e2f5bf extend zlib export required for the recent libpng 2017-04-23 21:33:14 +02:00
Anatol Belski
144ddd3b42 Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0:
  extend zlib export required for the recent libpng
2017-04-23 21:28:26 +02:00
Anatol Belski
2909742326 extend zlib export required for the recent libpng 2017-04-23 21:27:34 +02:00
Bob Weinand
f3ab4c1a08 Merge branch 'PHP-7.0' into PHP-7.1 2017-03-15 00:09:42 +01:00
Matt Bonneau
7fba8bda4c Fixed bug #74240 (deflate_add can allocate too much memory) 2017-03-15 00:08:32 +01:00
Nikita Popov
b38e6a54cf Merge branch 'PHP-7.0' into PHP-7.1 2017-01-08 13:48:48 +01:00
Nikita Popov
b36f4ac708 deflate_add(): Don't add unnecessary +1 to size
zend_string_realloc will do this by itself.
2017-01-08 13:47:20 +01:00
Sammy Kaye Powers
dac6c639bb Update copyright headers to 2017 2017-01-04 11:23:42 -06:00
Sammy Kaye Powers
478f119ab9 Update copyright headers to 2017 2017-01-04 11:14:55 -06:00
Bob Weinand
898e439333 Merge branch 'PHP-7.0' into PHP-7.1 2016-12-22 15:31:39 +01:00
Bob Weinand
8823b68c41 Fixed bug #73373 (deflate_add does not verify that output was not truncated) 2016-12-22 15:29:36 +01:00
Christoph M. Becker
c2b29a58bc Merge branch 'PHP-7.0' 2016-07-04 03:20:01 +02:00
Christoph M. Becker
60fc27f912 Merge branch 'PHP-5.6' into PHP-7.0 2016-07-04 03:18:50 +02:00
Christoph M. Becker
717a043a32 Fix typo in comment 2016-07-04 03:17:17 +02: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
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
Anatol Belski
1cca3eb7c8 fix test portability 2016-06-13 15:47:08 +02:00
Nikita Popov
1ac152938c Move semicolon into TSRMLS_CACHE_EXTERN/DEFINE
Also re bug #71575.
2016-03-03 16:50:01 +01:00
Nikita Popov
c9357f82d3 Format string fixes
Conflicts:
	ext/pgsql/pgsql.c
2016-02-14 14:45:53 +01:00
Stanislav Malyshev
e231830f16 Merge branch 'PHP-5.6.18' into PHP-7.0.3
* PHP-5.6.18:
  fix tests
  fix NEWS
  Update NEWS
  update NEWS
  Fixed bug #71488: Stack overflow when decompressing tar archives
  update NEWS
  add missing headers for SIZE_MAX
  backport the escapeshell* functions hardening branch
  add tests
  Fix bug #71459 - Integer overflow in iptcembed()
  prepare 5.6.18RC1
  Fix test when run with openssl < 1.0.2 (reorder so no more SSLv2 message) Fix skip message to work
  improve fix for bug #71201
  Fixed bug #71323 - Output of stream_get_meta_data can be falsified by its input
  Fix bug #71391: NULL Pointer Dereference in phar_tar_setupmetadata()
  Fixed bug #71331 - Uninitialized pointer in phar_make_dirstream()
  Fix bug #71335: Type Confusion in WDDX Packet Deserialization
  Fix bug #71354 - remove UMR when size is 0

Conflicts:
	configure.in
	ext/phar/dirstream.c
	ext/phar/phar_object.c
	ext/phar/tar.c
	ext/standard/exec.c
	ext/standard/iptc.c
	ext/standard/math.c
	ext/standard/streamsfuncs.c
	ext/wddx/wddx.c
	main/php_version.h
	main/streams/memory.c
2016-02-01 20:00:01 -08:00
Stanislav Malyshev
24167095a5 Merge branch 'PHP-5.5' into PHP-5.6.18
* PHP-5.5:
  fix tests
  fix NEWS
  update NEWS
2016-02-01 19:15:19 -08:00
Stanislav Malyshev
2a7d8c0a06 fix tests 2016-02-01 18:58:02 -08:00
Lior Kaplan
ed35de784f Merge branch 'PHP-5.6' into PHP-7.0
* PHP-5.6:
  Happy new year (Update copyright to 2016)
2016-01-01 19:48:25 +02:00
Lior Kaplan
49493a2dcf Happy new year (Update copyright to 2016) 2016-01-01 19:21:47 +02:00
marcosptf
d536ecac5c added test for gzgetss() 2015-08-23 17:55:23 +02:00
Julien Pauli
aae9004ebd Removed dead code 2015-08-17 17:18:25 +02:00
Anatol Belski
4e66cce87c switch to the unified globals accessor where appropriate 2015-07-29 13:26:35 +02:00
Nikita Popov
90d9adccec Fix zlib_filter warnings 2015-07-17 19:48:06 +02:00
Dmitry Stogov
4a2e40bb86 Use ZSTR_ API to access zend_string elements (this is just renaming without semantick changes). 2015-06-30 04:05:24 +03:00
Kalle Sommer Nielsen
db22946b25 Remove these old references to the DSP files we don't use anymore 2015-06-22 13:29:42 +02:00
Bob Weinand
9b6bb2d451 Add support for string dictionaries, fix array dictionaries ({de,in}flate) 2015-05-21 04:17:17 +02:00
Bob Weinand
6868b56e25 Fix unrelated tests and zlib window size 2015-05-15 13:59:47 +02:00
Bob Weinand
00ea48ad43 Minor typo in warning message 2015-05-15 02:42:11 +02:00
Bob Weinand
227a21b297 Add strategy option to deflate_init() 2015-05-15 02:28:38 +02:00
Bob Weinand
dd17e18f41 Add dictionary option to {in,de}flate_init() 2015-05-15 02:28:38 +02:00
Bob Weinand
a129ded3c1 Add window option to {de,in}flate_init() 2015-05-15 02:28:37 +02:00
Daniel Lowrey
c488172975 Improve ZBLOCK handling with zlib < 1.2.4
The original commit for this issue (62b1293) assumed Z_BLOCK was
only defined in < 1.2.4. However, this flush type *is* defined but
is only unavailable for use with deflate().

This new commit correctly checks the ZLIB_VERNUM constant to
determine if Z_BLOCK flush is available for the current deflate()
operation and triggers an appropriate error as needed.

New ZLIB_VERSION and ZLIB_VERNUM constants are also exposed in
userland to allow testing this behavior in environments running
zlib < 1.2.4 (ZLIB_VERNUM check is needed).
2015-05-07 10:31:41 -04:00
Daniel Lowrey
62b1293e3d Fix Z_BLOCK breakage when built against zlib < 1.2.4 2015-05-07 09:02:38 -04:00
Nikita Popov
40e465e357 Clean up some type conversions
While at it also fix some type checks in iconv and drop dead and
unported code in standard/filters.
2015-04-27 18:50:08 +02:00
Nikita Popov
300b1db09f Tweak new deflate/inflate implementations
Return NULL on zpp.
Don't manually cast zvals to long.
2015-04-25 19:00:41 +02:00
Daniel Lowrey
38ea6a827e Fix vim folding block 2015-04-24 09:27:24 -06:00
Daniel Lowrey
852904173e Merge branch 'deflate'
* deflate:
  Add inflate_*() test cases
  Add incremental zlib inflate API
  Add deflate_*() test cases
  Several deflate_* changes (more after the jump)
  Add incremental zlib deflate API
2015-04-24 09:02:59 -06:00
Daniel Lowrey
0e62416101 Add inflate_*() test cases 2015-04-23 23:50:59 -06:00