Commit Graph

236 Commits

Author SHA1 Message Date
Dmitry Stogov
44e0b79ac6 Refactored array creation API. array_init() and array_init_size() are converted into macros calling zend_new_array(). They are not functions anymore and don't return any values. 2017-09-20 02:25:56 +03:00
Anatol Belski
2d60b35147 Merge branch 'PHP-7.1' into PHP-7.2
* PHP-7.1:
  Add symbol to libxml exports
2017-09-11 17:37:10 +02:00
Anatol Belski
75cb69740e Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0:
  Add symbol to libxml exports
2017-09-11 17:36:25 +02:00
Anatol Belski
04a6bbae6c Add symbol to libxml exports 2017-09-11 17:35:25 +02:00
Nikita Popov
d9886614dc Merge branch 'PHP-7.1' 2017-06-03 00:42:38 +02:00
Nikita Popov
d9fd44366d Merge branch 'PHP-7.0' into PHP-7.1 2017-06-03 00:42:30 +02:00
Tim Toohey
d027bc2add Fixed bug #69373
xmlNodeSetContentLen() calls xmlFreeNode() on node->children. This
causes problems if there are other references around to those children.
2017-06-03 00:40:58 +02: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
Sammy Kaye Powers
9e29f841ce Update copyright headers to 2017 2017-01-02 09:30:12 -06:00
Sara Golemon
a470a8c0a0 Use new param API in libxml 2016-12-31 08:38:14 -08:00
Christoph M. Becker
ef0279b640 Merge branch 'PHP-7.0' 2016-07-15 01:22:26 +02:00
Christoph M. Becker
b01b093ca9 Merge branch 'PHP-5.6' into PHP-7.0 2016-07-15 01:14:41 +02:00
Christoph M. Becker
a4aa4f9772 Fix bug #66502: DOM document dangling reference
When we decrement the refcount of a node's document, we state that we
won't need it anymore. Therefore we can *always* set the pointer to the
document to NULL, what avoids invalid memory accesses for some edge cases
as demonstrated with the PHPT.

Original patch provided by Sean Heelan.
2016-07-15 01:08:08 +02:00
Anatol Belski
d0c98366d0 Merge branch 'PHP-5.5' into PHP-5.6
* PHP-5.5:
  Extend libxml exports
  Updated NEWS
  Fix #69975: PHP segfaults when accessing nvarchar(max) defined columns
  Updated NEWS
  Fix bug #70480 (php_url_parse_ex() buffer overflow read)
  Update PHP 5.5 NEWS entries with CVE info
2016-07-14 21:13:49 +02:00
Anatol Belski
fe1d6feb3d Extend libxml exports
These are needed to support libxslt 1.1.29 on Windows. This libxslt version
fixes CVE-2015-7995 and for this reason needs to be used.
2016-07-14 21:08:54 +02: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
Dmitry Stogov
ff363e2e7c Implemented RFC: Replace "Missing argument" warning with "Too few arguments" exception
Squashed commit of the following:

commit 8b45fa2acb
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Thu Jun 16 01:52:50 2016 +0300

    Separate slow path of ZEND_RECV into a cold function.

commit 9e18895ee5
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Wed Jun 15 23:26:28 2016 +0300

    Required argument can't be IS_UNDEF anymore.

commit 662db66e39
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Tue May 31 17:14:50 2016 +0300

    Replace "Missing argument" warning by "Too few arguments" exception.
2016-06-16 02:32:02 +03:00
Nikita Popov
1ac152938c Move semicolon into TSRMLS_CACHE_EXTERN/DEFINE
Also re bug #71575.
2016-03-03 16:50:01 +01:00
Anatol Belski
93592a9c08 Fix bug #71536 Access Violation crashes php-cgi.exe 2016-02-28 11:02:01 +01: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
Dmitry Stogov
560e4fa393 Removed or simplified incorrect SEPARATE_*() macros usage. 2015-09-29 11:17:43 +03:00
Xinchen Hui
3fc5f5cdb5 Fixed bug #70535 (XSLT: free(): invalid pointer) 2015-09-20 09:30:50 -07:00
Anatol Belski
4e66cce87c switch to the unified globals accessor where appropriate 2015-07-29 13:26:35 +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
Christoph M. Becker
b8d8c75c4c added LIBXML_BIGLINES constant 2015-06-08 09:59:37 +02:00
Christoph M. Becker
a1951c2e0a added tests for bug #54138 2015-06-08 09:59:36 +02:00
Christoph M. Becker
f661b10536 replaced / in filename with DIRECTORY_SEPARATOR according to performance warning on DOMDocument::load man page 2015-06-08 09:40:06 +02:00
Christoph M. Becker
03399721f4 added SKIPIF conditional to check for DOM availability 2015-06-08 09:40:05 +02:00
Christoph M. Becker
5fed10e109 added XFAIL test for bug #69753 2015-06-08 09:40:04 +02:00
Anatol Belski
06332e6706 introduced DllMain for the main php DLL
The particular need on this is because of the current situation
with determining the background functionality for the
gettimeofday. DllMain allows to initialize stuff before the DLL
can be actually used. Thus, we use different time API on win7
and win8 and later, so the function pointer needs to be
initialized before anything in the DLL could even demand it.

The change also opens the door for the further optimizations,
as now we're able to do the very basic initializations for the
whole DLL before it could ever start to live. Fe on this way the
TLS initialization could be done, when utilizing the
DLL_THREAD_ATTACH/DETACH case. Whether it's really usable in
portable way should be synced with other platforms.

Be aware that it's dangerous as it possibly causes dead locks.
So to use with care. One willing to add items to DllMain should
better read the documentation twice and even then try to defer
the necessary action.
2015-06-02 15:56:32 +02:00
Anatol Belski
b312a7ee38 extend libxml exports 2015-05-13 15:20:20 +02:00
Anatol Belski
becfdeb2ff improve searchability for libxml2 headers
and bring the configs inline with the current libxml2 build
2015-05-10 22:22:03 +02:00
Anatol Belski
2d78023244 cleanup the mod version macros, round 2 2015-03-23 20:33:54 +01:00
Anatol Belski
293d6e629d backport af2b0669 into 5.5 2015-03-16 08:32:39 +01:00
Anatol Belski
8f0dbe2355 Merge branch 'PHP-5.6'
* PHP-5.6:
  libxml-2.9.2 compatibility
2015-03-15 18:39:38 +01:00
Anatol Belski
af2b066911 libxml-2.9.2 compatibility 2015-03-15 18:38:50 +01:00
Anatol Belski
8742276eb3 abstain from using xmlCleanupParser
Depending on circumstances, usage of xmlCleanupParser can affect
the thread local storage, or even cause crashes in single threaded
programs. On shutdown the memory will be freed anyway, however
not using xmlCleanupParser helps to avoid possible shutdown
crashes.
2015-02-17 10:37:52 +01:00
Anatol Belski
af3ca74501 made ZEND_TSRMLS_CACHE_* macros look like function calls
which also comply with the current semantics for such macros
2015-02-16 17:19:32 +01:00
Stanislav Malyshev
463611714c Merge branch 'PHP-5.5' into PHP-5.6
* PHP-5.5:
  Fix bug #64938: libxml_disable_entity_loader setting is shared between threads
2015-02-01 00:09:04 -08:00
Martin Jansen
de31324c22 Fix bug #64938: libxml_disable_entity_loader setting is shared between threads
The availability of entity loading is stored in a module global which
previously was only initialized in the GINIT constructor. This had the
effect that disabling the entity loader in one request caused
subsequent requests hitting the same Apache child process to  also have
the loader disabled.

With this change the loader is explicitely enabled in the request init
phase.
2015-02-01 00:08:35 -08:00
Martin Jansen
3a39f3ad70 Fix typos 2015-01-22 21:08:28 +01:00
Martin Jansen
c1eb87ab1a Fix bug #64938: libxml_disable_entity_loader setting is shared between threads
The availability of entity loading is stored in a module global which
previously was only initialized in the GINIT constructor. This had the
effect that disabling the entity loader in one request caused
subsequent requests hitting the same Apache child process to  also have
the loader disabled.

With this change the loader is explicitely enabled in the request init
phase.
2015-01-22 20:58:15 +01:00
Xinchen Hui
fc33f52d8c bump year 2015-01-15 23:27:30 +08:00
Xinchen Hui
0579e8278d bump year 2015-01-15 23:26:37 +08:00
Xinchen Hui
73c1be2653 Bump year 2015-01-15 23:26:03 +08:00
Stanislav Malyshev
b7a7b1a624 trailing whitespace removal 2015-01-10 15:07:38 -08:00
Anatol Belski
bdeb220f48 first shot remove TSRMLS_* things 2014-12-13 23:06:14 +01:00
Anatol Belski
3ca0ca1548 Merge remote-tracking branch 'origin/master' into native-tls
* origin/master: (102 commits)
  fix dir separator in test
  fix TS build
  fix TS build
  Better fix for bug #68446
  Revert "Merge remote-tracking branch 'origin/PHP-5.6'"
  Revert NEWS and set test to XFAIL
  Revert "Fix bug #68446 (bug with constant defaults and type hints)"
  Improved zend_hash_clean() and added new optimized zend_symtable_clean()
  Use inline version of zval_ptr_dtor()
  Added new optimized zend_array_destroy() function
  Moved i_zval_ptr_dtor() from zend_execute.h to zend_variables.h
  fix REGISTER_NS_*_CONSTANT macros
  Removed useless assert. EG(uninitialized_zval) can't be refcounted.
  Use specialized destructors when types of zvals are known.
  move tests into proper place
  Improved assignment to object property
  Reuse zend_assign_to_variable() in zend_std_write_property()
  cleanup comments from svn/cvs era
  fix dir separator in test
  fork test for windows
  ...
2014-11-26 08:17:35 +01:00