Commit Graph

185 Commits

Author SHA1 Message Date
Peter Kokot
f1d7e3ca0b Sync leading and final newlines in *.phpt sections
This patch adds missing newlines, trims multiple redundant final
newlines into a single one, and trims redundant leading newlines in all
*.phpt sections.

According to POSIX, a line is a sequence of zero or more non-' <newline>'
characters plus a terminating '<newline>' character. [1] Files should
normally have at least one final newline character.

C89 [2] and later standards [3] mention a final newline:
"A source file that is not empty shall end in a new-line character,
which shall not be immediately preceded by a backslash character."

Although it is not mandatory for all files to have a final newline
fixed, a more consistent and homogeneous approach brings less of commit
differences issues and a better development experience in certain text
editors and IDEs.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206
[2] https://port70.net/~nsz/c/c89/c89-draft.html#2.1.1.2
[3] https://port70.net/~nsz/c/c99/n1256.html#5.1.1.2
2018-10-15 04:31:31 +02:00
Peter Kokot
17ccbeec32 Trim trailing whitespace in *.phpt 2018-10-14 19:44:14 +02:00
Peter Kokot
60a69daec6 Sync leading and final newlines in source code files
This patch adds missing newlines, trims multiple redundant final
newlines into a single one, and trims redundant leading newlines.

According to POSIX, a line is a sequence of zero or more non-' <newline>'
characters plus a terminating '<newline>' character. [1] Files should
normally have at least one final newline character.

C89 [2] and later standards [3] mention a final newline:
"A source file that is not empty shall end in a new-line character,
which shall not be immediately preceded by a backslash character."

Although it is not mandatory for all files to have a final newline
fixed, a more consistent and homogeneous approach brings less of commit
differences issues and a better development experience in certain text
editors and IDEs.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206
[2] https://port70.net/~nsz/c/c89/c89-draft.html#2.1.1.2
[3] https://port70.net/~nsz/c/c99/n1256.html#5.1.1.2
2018-10-14 12:54:08 +02:00
Peter Kokot
102cf75eeb Merge branch 'PHP-7.1' into PHP-7.2
* PHP-7.1:
  Fix failing ext/zlib/tests due to whitespace
2018-10-13 15:15:39 +02:00
Peter Kokot
9120e79e9f Fix failing ext/zlib/tests due to whitespace 2018-10-13 15:15:26 +02:00
Peter Kokot
902d39a3a7 Trim trailing whitespace in source code files 2018-10-13 14:14:50 +02:00
Peter Kokot
7f6387b59a Trim trailing whitespace in source code files 2018-10-13 14:12:55 +02:00
Christoph M. Becker
fa70b91a4f Merge branch 'PHP-7.1' into PHP-7.2
* PHP-7.1:
  Fix #75273: php_zlib_inflate_filter() may not update bytes_consumed
2018-09-08 19:09:56 +02:00
Christoph M. Becker
90d863898c Fix #75273: php_zlib_inflate_filter() may not update bytes_consumed
Whenever we return with `PSFS_PASS_ON`, we need to update
`bytes_consumed` to not mislead the caller.  Instead of fixing the
respective `if` clauses, we eschew the early bail-outs to simplify the
code a bit.
2018-09-08 19:01:36 +02:00
Christoph M. Becker
1f150fcde1 Merge branch 'PHP-7.1' into PHP-7.2
* PHP-7.1:
  Fix Bug #75299 Wrong reflection on inflate_init and inflate_add
2017-10-11 17:30:45 +02:00
Christoph M. Becker
d3d23e0cb8 Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0:
  Fix Bug #75299 Wrong reflection on inflate_init and inflate_add
2017-10-11 17:29:36 +02:00
Fabien Villepinte
9d9873b3b5 Fix Bug #75299 Wrong reflection on inflate_init and inflate_add 2017-10-01 11:27:16 +02:00
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
Tom Van Looy
04fb3f28ff Remove superfluous semicolons 2017-06-26 00:23:25 +02:00
Bob Weinand
a1755671e2 Merge branch 'PHP-7.1' 2017-06-25 20:15:31 +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
191f154d40 Merge branch 'PHP-7.1' 2017-06-25 15:32:38 +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
ba64ec0b13 improve zlib version check for tests 2017-03-22 11:08:38 +01:00
Anatol Belski
f258e9b803 make test more flexible to match different compressed strings
particurarly needed with zlib 1.2.11
2017-03-22 11:08:37 +01:00
Bob Weinand
8a7a1411b9 Merge branch 'PHP-7.1' 2017-03-15 00:09:59 +01: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
Bob Weinand
712c532ab9 Merge branch 'PHP-7.1' 2016-12-22 15:31:58 +01: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
Pedro Magalhães
9c5af4e4cb Remove the b prefix from literals on unrelated tests 2016-11-20 21:11:53 +01: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
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
marcosptf
d536ecac5c added test for gzgetss() 2015-08-23 17:55:23 +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
dd17e18f41 Add dictionary option to {in,de}flate_init() 2015-05-15 02:28:38 +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
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
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
Daniel Lowrey
4d5324088c Add deflate_*() test cases 2015-04-23 23:49:41 -06:00
Stanislav Malyshev
b3709bfc52 Merge branch 'PHP-5.6'
* PHP-5.6: (27 commits)
  fix non-standard C
  update NEWS
  5.4.41 next
  fix CVE num
  update NEWS
  Fix bug #69441 (Buffer Overflow when parsing tar/zip/phar in phar_set_inode)
  fix test
  fix type in fix for #69085
  fix memory leak & add test
  Fix tests
  fix CVE num
  Fix bug #69337 (php_stream_url_wrap_http_ex() type-confusion vulnerability)
  Fix test
  Additional fix for bug #69324
  More fixes for bug #69152
  Fixed bug #69353 (Missing null byte checks for paths in various PHP extensions)
  Fixed bug #69324 (Buffer Over-read in unserialize when parsing Phar)
  Fixed bug #69316 (Use-after-free in php_curl related to CURLOPT_FILE/_INFILE/_WRITEHEADER)
  Fix bug #68486 and bug #69218 (segfault in apache2handler with apache 2.4)
  Fix bug #68819 (Fileinfo on specific file causes spurious OOM and/or segfault)
  ...

Conflicts:
	Zend/zend_exceptions.c
	ext/curl/interface.c
	ext/dom/document.c
	ext/fileinfo/libmagic/softmagic.c
	ext/gd/gd.c
	ext/hash/hash.c
	ext/pgsql/pgsql.c
	ext/phar/phar.c
	ext/phar/phar_internal.h
	ext/standard/http_fopen_wrapper.c
	ext/standard/link.c
	ext/standard/streamsfuncs.c
	ext/xmlwriter/php_xmlwriter.c
	ext/zlib/zlib.c
2015-04-14 01:28:06 -07:00
Stanislav Malyshev
5776fceb16 Merge branch 'PHP-5.5' into PHP-5.6
* PHP-5.5: (27 commits)
  fix non-standard C
  update NEWS
  5.4.41 next
  fix CVE num
  update NEWS
  Fix bug #69441 (Buffer Overflow when parsing tar/zip/phar in phar_set_inode)
  fix test
  fix type in fix for #69085
  fix memory leak & add test
  Fix tests
  fix CVE num
  Fix bug #69337 (php_stream_url_wrap_http_ex() type-confusion vulnerability)
  Fix test
  Additional fix for bug #69324
  More fixes for bug #69152
  Fixed bug #69353 (Missing null byte checks for paths in various PHP extensions)
  Fixed bug #69324 (Buffer Over-read in unserialize when parsing Phar)
  Fixed bug #69316 (Use-after-free in php_curl related to CURLOPT_FILE/_INFILE/_WRITEHEADER)
  Fix bug #68486 and bug #69218 (segfault in apache2handler with apache 2.4)
  Fix bug #68819 (Fileinfo on specific file causes spurious OOM and/or segfault)
  ...

Conflicts:
	ext/standard/http_fopen_wrapper.c
2015-04-14 01:05:01 -07:00
Stanislav Malyshev
ba15e8dfd0 Merge branch 'PHP-5.4.40' into PHP-5.5.24
* PHP-5.4.40:
  fix memory leak & add test
  Fix tests
2015-04-12 23:49:16 -07:00
Stanislav Malyshev
a643ccfb90 Fix tests 2015-04-12 20:55:35 -07:00