Commit Graph

12096 Commits

Author SHA1 Message Date
Nikita Popov
ba09a520d2 Cleanup parameter/return type checking code
a) Extract all the logic for error message formatting into a separate
function that is reused for everything.
b) Extract the logic for whether a value matches a type into two
functions, one for user types, one for internal ones.

This tries to fight the increasing code duplication in the type
checking code, whether everything was repeated at least four times
and parts of the error message handling were repeated in dozens of
branches.
2016-08-16 15:48:33 +02:00
Nikita Popov
1397f754c8 Fix handling of qualified nullable parameter types
compile_typename() can't deal with TYPE_NULLABLE flags, drop it
beforehand.
2016-08-16 12:43:17 +02:00
Dmitry Stogov
ff06588130 Fixed use after free 2016-08-16 11:44:22 +03:00
Stanislav Malyshev
c2a13ced42 Fix bug #72742 - memory allocator fails to realloc small block to large one 2016-08-14 19:08:59 -07:00
Xinchen Hui
dd618664a0 Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0:
  Fixed bug #72813 (Segfault with __get returned by ref)
  Fix URL rewriter partially

Conflicts:
	Zend/zend_object_handlers.c
	ext/standard/url_scanner_ex.c
	ext/standard/url_scanner_ex.re
2016-08-12 16:35:41 +08:00
Xinchen Hui
e03480bfab Fixed bug #72813 (Segfault with __get returned by ref)
This should be safe change, as we don't dereference value and member
after calling setter/getter.

And compare to adding unref codes, this is much cheaper.
2016-08-12 16:24:46 +08:00
Andrea Faulds
1dab96c1db Show "or null" in TypeErrors for nullable arg_infos 2016-08-11 18:44:43 +02:00
Davey Shafik
b33e965111 Use non-deprecated %pure-parser 2016-08-11 18:29:55 +02:00
Joey
194ffefb9e Corrected typo in comment
Finger-key interface malfunction.
2016-08-11 18:28:50 +02:00
Andrea Faulds
ab45f13a0b Merge branch 'PHP-7.0' into PHP-7.1 2016-08-08 21:00:49 +01:00
Andrea Faulds
5358c7cf5e Replace dead branch with ZEND_ASSERT() 2016-08-08 20:56:11 +01:00
Nikita Popov
3859bcd1f8 Merge branch 'PHP-7.0' into PHP-7.1 2016-08-05 19:56:27 +02:00
Nikita Popov
807e81937b Fix bug #72767
The page size calculation did not account for the size of the
stack header (or rather it did account for it, but in the wrong
direction...)
2016-08-05 19:55:10 +02:00
Nikita Popov
ec6d70db77 Fix leak on self-referencing constants 2016-08-03 23:10:09 +02:00
Nikita Popov
ca82574d7c Fix invalid free on undef const in update_const()
Also clean up the control flow a bit -- move all unqualified
constant handling in one branch.
2016-07-30 00:37:01 +02:00
Nikita Popov
3b48c5a36f Revert "Make call_user_func() on reference args consistent"
This reverts commit fafe01b07b.

See bug #72698, there is code using this behavior. Reverting for
PHP 7.0 *only*. The fix is still in PHP 7.1.
2016-07-28 18:45:44 +02:00
Bob Weinand
dfb3e270c2 Merge remote-tracking branch 'origin/PHP-7.0' into PHP-7.1 2016-07-27 18:18:47 +02:00
Bob Weinand
5513f00a97 Fixed a potential segfault in zend_objects_store_free_object_storage()
Under the special circumstance where a garbage collected objects bucket slot was not reused until the end of the script, we get access into freed memory...
No test added as it usually is valgrind-only, and only sometimes when the memory happens to have changed (i.e. (GC_FLAGS(obj) & IS_OBJ_FREE_CALLED) == 0), it actually *may* segfault
2016-07-27 18:08:43 +02:00
Bob Weinand
35764e3579 Merge remote-tracking branch 'origin/PHP-7.0' into PHP-7.1 2016-07-23 16:40:02 +02:00
Bob Weinand
6046acf93e Fix ClosedGeneratorException possibly thrown into wrong scope 2016-07-23 16:39:21 +02:00
Nikita Popov
f4d1af7981 Fix build
Missed this occurrence...
2016-07-23 00:12:11 +02:00
Nikita Popov
07af6ba898 Make sure TOKEN_PARSE mode is thread safe
Introduce an on_event_context passed to the on_event hook. Use this
context to pass along the token array. Previously this was stored
in a non-tls global :/
2016-07-23 00:00:13 +02:00
Xinchen Hui
5296853fff Merge branch 'PHP-7.0'
* PHP-7.0:
  Fixed typo
2016-07-20 17:01:53 +08:00
Xinchen Hui
cbbe17fb53 Fixed typo 2016-07-20 17:01:42 +08:00
Xinchen Hui
9254f5d5d3 Merge branch 'PHP-7.0'
* PHP-7.0:
  Fixed bug #72629 (Caught exception assignment to variables ignores references).

Conflicts:
	main/php_version.h
2016-07-20 17:00:09 +08:00
Xinchen Hui
97c0b133c5 Fixed bug #72629 (Caught exception assignment to variables ignores references). 2016-07-20 16:59:14 +08:00
Anatol Belski
ab39b094d2 Merge branch 'PHP-7.0'
* PHP-7.0:
  Fix for bug #72513
2016-07-19 17:23:51 +02:00
Stanislav Malyshev
374ae8e9da Fix for bug #72513
This is applicable to 7 as well, but was somehow missing from the merge.
2016-07-19 17:18:24 +02:00
Stanislav Malyshev
4d0565b5ba Merge branch 'PHP-5.5' into PHP-5.6
* PHP-5.5:
  fix #72519, possible OOB using imagegif
  fix #72512, invalid read or write for palette image when invalid transparent index is used
  Apparently some envs miss SIZE_MAX
  Fix tests
  Fix bug #72618: NULL Pointer Dereference in exif_process_user_comment
  Partial fix for bug #72613 - do not treat negative returns from bz2 as size_t
  Fix bug #72606: heap-buffer-overflow (write) simplestring_addn simplestring.c
  Fix for bug #72558, Integer overflow error within _gdContributionsAlloc()
  Fix bug #72603: Out of bound read in exif_process_IFD_in_MAKERNOTE
  Fix bug #72562 - destroy var_hash properly
  Fix bug #72533 (locale_accept_from_http out-of-bounds access)
  Fix fir bug #72520
  Fix for bug #72513
  CS fix and comments with bug ID
  Fix for HTTP_PROXY issue.
  add tests for bug #72512
  Fixed bug #72512 gdImageTrueColorToPaletteBody allows arbitrary write/read access
  Fixed bug #72479 - same as #72434

Conflicts:
	ext/bz2/bz2.c
	main/SAPI.c
	main/php_variables.c
2016-07-19 00:53:08 -07:00
Stanislav Malyshev
1a88692692 Merge branch 'PHP-5.6.24' into PHP-5.6
* PHP-5.6.24:
  Fix for bug #72513
  5.6.24RC1

Conflicts:
	configure.in
	main/php_version.h
2016-07-19 00:51:27 -07:00
Nikita Popov
cbba1fff3f Fix leak if get_iterator throws but doesn't return NULL 2016-07-16 23:16:34 +02:00
Nikita Popov
0242845536 Merge branch 'PHP-7.0' 2016-07-16 23:03:01 +02:00
Nikita Popov
31cbe23a9a Merge branch 'PHP-5.6' into PHP-7.0
Conflicts:
	Zend/zend_gc.c
2016-07-16 23:02:34 +02:00
Nikita Popov
171c759d79 Revert "Fixed bug #72286 (Segmentation fault During Garbage Collection)"
This reverts commit 1c84b55ade.
2016-07-16 23:02:23 +02:00
Nikita Popov
664e5f392d Merge branch 'PHP-7.0' 2016-07-14 21:41:49 +02:00
Nikita Popov
a50a5c1bf1 Fix is_callable() on abstract method via object 2016-07-14 21:41:41 +02:00
Dmitry Stogov
92e158e3c4 Merge branch 'PHP-7.0'
* PHP-7.0:
  Fixed bug #72286 (Segmentation fault During Garbage Collection)
2016-07-14 22:39:15 +03:00
Dmitry Stogov
99a5170781 Merge branch 'PHP-5.6' into PHP-7.0
* PHP-5.6:
  Fixed bug #72286 (Segmentation fault During Garbage Collection)
2016-07-14 22:38:47 +03:00
Dmitry Stogov
1c84b55ade Fixed bug #72286 (Segmentation fault During Garbage Collection) 2016-07-14 22:37:25 +03:00
Nikita Popov
a26748d7be Fix bad merge
In master the operand is fetched earlier, I didn't account for
that.
2016-07-14 20:44:36 +02:00
Nikita Popov
37a2f3fe25 Fix leak if get_constructor returns NULL 2016-07-14 18:42:46 +02:00
Nikita Popov
eba5466f10 Fix leaks if update_constant fails 2016-07-14 18:42:45 +02:00
Nikita Popov
0bda0422af Merge branch 'PHP-7.0'
Conflicts:
	Zend/zend_vm_execute.h
2016-07-14 18:39:48 +02:00
Nikita Popov
00047fcf84 Fix leak when dynamically calling abstract method 2016-07-14 18:39:08 +02:00
Nikita Popov
587668be56 Fix leak of class name when printing exception backtrace 2016-07-14 18:38:58 +02:00
Nikita Popov
c3804a2cf9 Fix leaks in yield from error conditions
Conflicts:
	Zend/zend_vm_execute.h
2016-07-14 18:38:45 +02:00
Nikita Popov
d1f82bfeb2 Fix leak for by-ref assign to overloaded object
Conflicts:
	Zend/zend_vm_execute.h
2016-07-14 18:38:04 +02:00
Nikita Popov
82ce2a4e4d Add missing call opcodes in cleanup_unfinished_calls()
Otherwise we may leak if an exception is thrown from them.
2016-07-14 18:37:28 +02:00
Nikita Popov
5063b5aea1 Fix leak if throw_exception_object() fails 2016-07-14 18:37:21 +02:00
Nikita Popov
e3e400c983 Fix return from by-ref generators 2016-07-14 15:44:04 +02:00
Dmitry Stogov
9a76189caf Fixed memory leak 2016-07-14 13:14:15 +03:00
Dmitry Stogov
f80bb059b3 Fixed memory leak 2016-07-14 13:05:27 +03:00
Dmitry Stogov
8fc934b0a1 Fixed bug #71818 (Memory leak when array altered in destructor) 2016-07-14 12:05:44 +03:00
Xinchen Hui
efdc8ccd52 Merge branch 'PHP-7.0'
* PHP-7.0:
  Fixed bug #72594 (Calling an earlier instance of an included anonymous class fatals)

Conflicts:
	Zend/zend_compile.c
2016-07-14 13:38:27 +08:00
Xinchen Hui
8c5b27e061 Fixed bug #72594 (Calling an earlier instance of an included anonymous class fatals) 2016-07-14 13:36:43 +08:00
Dmitry Stogov
e6f04d4c8e Unified behavior of modification of returned by reference value in finnally code. 2016-07-13 20:35:53 +03:00
Dmitry Stogov
02dca0cf16 Removed wrong warning 2016-07-13 20:04:47 +03:00
Dmitry Stogov
afd3e39d66 Fixed bug #29368 (The destructor is called when an exception is thrown from the constructor). 2016-07-13 16:43:47 +03:00
Dmitry Stogov
3b8cb2119b Fixed bug #72347 (VERIFY_RETURN type casts visible in finally)
Fixed bug #72216 (Return by reference with finally is not memory safe)
Fixed bug #72215 (Wrong return value if var modified in finally)
2016-07-13 15:08:28 +03:00
Stanislav Malyshev
a099545bec Fix for bug #72513 2016-07-12 21:52:27 -07:00
Bob Weinand
7a125a4409 Remove bogus zend_signal_shutdown symbol from header 2016-07-13 01:05:32 +02:00
Keyur
b31f8be143 Safer signal handler (no malloc() call) 2016-07-12 17:17:04 +02:00
Xinchen Hui
7903276f4c backport to 5.6 (we should not unset the default value) 2016-07-12 12:14:45 +08:00
Xinchen Hui
0478e431cf Merge branch 'PHP-7.0'
* PHP-7.0:
  Fixed bug #72581 (previous property undefined in Exception after deserialization)

Conflicts:
	Zend/zend_exceptions.c
2016-07-12 11:52:21 +08:00
Xinchen Hui
42902919bc Fixed bug #72581 (previous property undefined in Exception after deserialization) 2016-07-12 11:51:20 +08:00
Bob Weinand
b00376884e Rewrite watchpoints to be much more stable
This mainly involves a separate abstraction layer for elements (e.g. $a->b) and watchpoints (on pointer of the Bucket for example).
Also better comparison handling (value backup vs. page dumps).

It is not yet finished (there are sometimes false positives announced and names not yet perfect), but the functionality is working and not crashing as far as I have tested.
Future scope is also relative watchpoints, e.g. "w $this->val expression()" which does not have the symbol tables as basis, but the value (in this example: return value of expression()) as basis.
2016-07-11 23:58:20 +02:00
c9s
9288ce5390 Add document for zend_gc_collect_cycles 2016-07-11 12:44:42 +02:00
Anatol Belski
6955790107 silence compiler noise 2016-07-11 09:24:04 +02:00
Nikita Popov
5f6effed43 Add opcodes to zend_wrong_string_offset() 2016-07-10 15:15:34 +02:00
Xinchen Hui
d77a8b052b This became unnecessary after #72543 is fixed 2016-07-07 15:25:27 +08:00
Dmitry Stogov
fbca255cd0 Fixed bug #71539 (Memory error on $arr[$a] =& $arr[$b] if RHS rehashes) 2016-07-07 00:59:44 +03:00
Nikita Popov
ab304579ff Forbid use of array() in nested destructuring
Previously array() was only forbidden on the outermost level.
2016-07-06 21:15:54 +02:00
Dmitry Stogov
023b812593 Fixed bug #72543 (Different references behavior comparing to PHP 5) 2016-07-06 20:46:43 +03:00
Nikita Popov
dbe6a23194 Closure::fromCallable(): Getting non-static method statically
As this is new functionality, I'm going directly for a TypeError,
rather than a deprecation warning.
2016-07-05 15:52:03 +02:00
Nikita Popov
ceae9fb540 Closure::fromCallable(): Better LSB handling
The previous fix missed the "late" part of "late static binding" :)
2016-07-05 15:44:17 +02:00
Nikita Popov
e959a9b652 Closure::fromCallable(): Fix late static binding 2016-07-05 15:31:11 +02:00
Nikita Popov
e395b62c51 Closure::fromCallable(): Use fake closures 2016-07-05 15:13:51 +02:00
Nikita Popov
03fbc27f07 Closure::fromCallable(): Fix test files and names 2016-07-05 15:13:51 +02:00
Nikita Popov
041476f4ae Closure::fromCallable(): Fix stack corruption
So the tests work at least...
2016-07-05 14:54:35 +02:00
Nikita Popov
2b46e3c710 Merge branch 'PHP-7.0' 2016-07-05 14:34:20 +02:00
Nikita Popov
8a555d7c66 Merge branch 'PHP-5.6' into PHP-7.0
Conflicts:
	Zend/zend_compile.c
2016-07-05 14:32:38 +02:00
Pedro Magalhães
08777e9615 Don't enforce LSP if prototype method is private
Fixes bug #72496.
2016-07-05 14:30:22 +02:00
Xinchen Hui
11d0101516 Some cleanup:
1. use c89 comments
2. exception should not be swallowd
3. ZVAL_OBJ may have problem if obj is NULL in the feature(who knows)
2016-07-05 15:31:46 +08:00
Aaron Piotrowski
3f108f50f9 Merge branch 'pull-request/1929' 2016-07-05 02:29:53 -05:00
Joe Watkins
f4a6b74667 Merge branch 'pull-request/1906' 2016-07-05 07:57:06 +01:00
Aaron Piotrowski
d9a9cf8eca Merge branch 'master' into iterable 2016-07-03 22:42:10 -05:00
Xinchen Hui
d1dd474ff9 Fixed bug #72523 (dtrace issue with reflection (failed test)) 2016-07-01 18:50:35 +08:00
Dmitry Stogov
1a14533806 Introduce new CHECK_VAR instruction to keep warnings about undefined variables. 2016-06-30 21:40:34 +03:00
Aaron Piotrowski
583386d59e Swap type check order 2016-06-29 09:36:33 -05:00
Nikita Popov
e48ded4bf8 Merge branch 'PHP-7.0' 2016-06-28 21:36:28 +02:00
Nikita Popov
9b8f1d6037 Don't use FUNC_ARG fetches for call_user_func()
This makes no sense -- SEND_USER can't even handle INDIRECTs.
2016-06-28 21:34:20 +02:00
Nikita Popov
45cfe7852a Merge branch 'PHP-7.0'
Conflicts:
	Zend/zend_vm_def.h
	Zend/zend_vm_execute.h
2016-06-28 20:57:55 +02:00
Nikita Popov
fafe01b07b Make call_user_func() on reference args consistent
Previously reference arguments were allowed if call_user_func()
was compiled to SEND_USER and not otherwise. Make it consistent
by always forbidding them.
2016-06-28 20:43:38 +02:00
Nikita Popov
cb7cc16c2d Use DO_UCALL for method calls 2016-06-28 12:05:03 +02:00
Dmitry Stogov
0cfb47651c Fixed compilation warnings 2016-06-28 11:37:51 +03:00
Xinchen Hui
b8a9e98166 Fixed build 2016-06-28 15:54:20 +08:00
Xinchen Hui
791d16834c Merge branch 'PHP-7.0'
* PHP-7.0:
  Fixed test
2016-06-28 15:39:10 +08:00
Xinchen Hui
76370f30db Fixed test 2016-06-28 15:39:02 +08:00
Xinchen Hui
3a4b8f6719 Merge branch 'PHP-7.0'
* PHP-7.0:
  Fixed bug #72508 (strange references after recursive function call and "switch" statement)
2016-06-28 15:36:58 +08:00
Xinchen Hui
ce7e180a04 Fixed bug #72508 (strange references after recursive function call and "switch" statement) 2016-06-28 15:36:50 +08:00
Dmitry Stogov
044e2718fe Fixed executor without global register variales (gcc warnings or clang errors) 2016-06-27 10:36:41 +03:00
Dmitry Stogov
a485ae2871 Fallback to kill() if raise() doesn't work 2016-06-24 19:32:24 +03:00
Dmitry Stogov
e5a8dd8ca9 Add temporary workaround for raise() failure 2016-06-24 18:00:47 +03:00
Xinchen Hui
03ebdb4616 Fixed unused var 2016-06-24 21:15:00 +08:00
Dmitry Stogov
a6387c0aa5 Added ability to make non-local control transfer through interrupt function 2016-06-24 12:20:41 +03:00
Anatol Belski
c9a538cdb4 improve ZEND_MODULE_GLOBALS_BULK macro, fix data type 2016-06-23 16:47:04 +02:00
Dmitry Stogov
13a2dde62a typo 2016-06-23 15:22:08 +03:00
Dmitry Stogov
d0460d8f6b Turn safe timeout handling into general interrupt handling ability. 2016-06-23 15:01:23 +03:00
Dmitry Stogov
f8faffe37e Merge branch 'PHP-7.0'
* PHP-7.0:
  Allow "proxy" ovjects to substitute their class names through get_class_name() handler (similar to var_dump() and others).
2016-06-22 17:28:59 +03:00
Dmitry Stogov
3c84e5e1ce Allow "proxy" ovjects to substitute their class names through get_class_name() handler (similar to var_dump() and others). 2016-06-22 17:23:04 +03:00
Dmitry Stogov
4ccbe03e44 Enable Zend signals by default 2016-06-21 20:14:19 +03:00
Dmitry Stogov
1433162083 Fixed compilation warnings 2016-06-21 20:12:29 +03:00
Dmitry Stogov
ebb99a1a3a Fixed compilation warnings 2016-06-21 16:55:17 +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
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
Stanislav Malyshev
3f627e580a Fixed ##72433: Use After Free Vulnerability in PHP's GC algorithm and unserialize 2016-06-20 21:26:33 -07:00
Dmitry Stogov
384224276d Enable Zend signals by default 2016-06-20 17:15:04 +03:00
Dmitry Stogov
bee4d7fd7b Reverted chunk committed by mistake. 2016-06-20 17:11:35 +03:00
Dmitry Stogov
c622cc4446 Fixed phpdbg build without --enable-zend-signals 2016-06-20 16:32:24 +03:00
Dmitry Stogov
4042f543c4 HANDLE_BLOCK/UNBLOCK_INTERRUPTIONS() protection on inter-process data is completely useless now.
Historicaly, these macros were introduced as a protection from execution timeout handling, but we don't need them anymore after "safe execution timeout" implementation.
These macros are still useful to protect from termination during inner process data modification, because of OS signals (e.g. SIGTERM during OPcache SHM update).
2016-06-20 15:50:41 +03:00
Dmitry Stogov
6ef43be1d7 Merge branch 'master' of git.php.net:php-src
* 'master' of git.php.net:php-src:
  Fixed the UTF-8 and long path support in the streams on Windows.
2016-06-20 14:59:35 +03:00
Dmitry Stogov
c8706331b5 Cleanup zend_signal API 2016-06-20 14:58:42 +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
Dmitry Stogov
3abd9c34c1 Removed unused callbacks 2016-06-20 13:27:59 +03:00
Xinchen Hui
fcd8a5ca65 Fixed bug #72441 (Segmentation fault: RFC list_keys) 2016-06-17 09:34:15 -07: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
Dmitry Stogov
a9512af810 Implemented RFC: Fix inconsistent behavior of $this variable
Squashed commit of the following:

commit bdd3b6895c
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Thu Jun 16 00:19:42 2016 +0300

    Fixed GOTO VM

commit 2f1d7c8b89
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Wed Jun 15 21:01:57 2016 +0300

    Removed unused variable

commit cf749c42b0
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Wed Jun 15 19:06:16 2016 +0300

    Protection from $this reassign through mb_parse_str()

commit 59a9a6c83c
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Wed Jun 15 18:14:50 2016 +0300

    Added type inference rule for FETCH_THIS opcode

commit 73f8d14a85
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Wed Jun 15 18:11:18 2016 +0300

    Restored PHP-7 behavior of isset($this->foo).
    It throws exception if not in object context.
    Removed useless opcode handlers.

commit fa0881381e
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Tue May 31 12:25:47 2016 +0300

    Changed "Notice: Undefined variable: this" into "Exception: Using $this when not in object context".

commit e32cc528c0
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Tue May 24 02:02:43 2016 +0300

    Throw exception on attempt to re-assign $this through extract() and parse_str().

commit 41f1531b52
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Mon May 23 22:18:36 2016 +0300

    Fixed inconsistent $this behavior
2016-06-16 02:30:23 +03:00
Dmitry Stogov
006b8417d1 Added specialized handlers for SEND_VAR/SEND_VAR_EX opcodes. 2016-06-15 23:07:46 +03:00
Xinchen Hui
493524454d Improve the signature 2016-06-14 08:05:17 -07:00
Xinchen Hui
d6e668368d C89 compatibility 2016-06-14 18:17:49 +08:00
Xinchen Hui
9c8e1c03b9 Only allow single comma in tail 2016-06-14 14:02:34 +08:00
Xinchen Hui
6166c26f1c Cleanup 2016-06-13 17:36:03 -07:00
Xinchen Hui
aeb3948f3c Cleanup 2016-06-13 09:33:19 -07:00
Xinchen Hui
f2fd469152 Merge branch 'master' of git.php.net:/php-src 2016-06-13 09:21:34 -07:00
Xinchen Hui
dcd1c29f79 Fixed bug #72395 (list() regression) 2016-06-13 09:21:14 -07:00
Nikita Popov
1b29e0cacd Switch zend_print_zval_r to use smart_str
Instead of directly writing to stdout. This allows doing a print_r
into a string, without using output buffering.

The motivation for this is bug #67467: print_r() in return mode
will still dump the string to stdout (causing a potential information
leak) if a fatal error occurs.
2016-06-13 18:04:22 +02:00
Xinchen Hui
ae3be78ce8 EG(fake_scope) was always set to NULL wrongly 2016-06-12 15:32:04 +08:00
Xinchen Hui
3f77db0510 cast const away 2016-06-11 16:11:40 +08:00
Nikita Popov
792e89385c Fixed bug #72373 2016-06-10 15:57:18 +02:00
Dmitry Stogov
e7e79aa409 Delay IS_ERROR checks 2016-06-09 12:39:38 +03:00
Dmitry Stogov
a315842751 typo 2016-06-08 19:01:28 +03:00
Nikita Popov
766ad0d970 Followup for bug #53432
Assign-ops and nested accesses now get the same treatment.
2016-06-08 15:43:58 +02:00
Dmitry Stogov
0c79896208 cleanup 2016-06-08 12:55:31 +03:00
Dmitry Stogov
b03dce0cb3 Replaced wrong check with proper ZEND_ASSERT() 2016-06-08 12:11:47 +03:00
Dmitry Stogov
fc587c7c55 Removed useless reference counting 2016-06-08 11:24:53 +03:00
Dmitry Stogov
3610156c5d This test was fixed together with fix for bug #70228 2016-06-08 11:14:06 +03:00
Dmitry Stogov
10f056255e Better fix for bug #70228 (memleak if return in finally block) 2016-06-08 02:20:45 +03:00
Dmitry Stogov
2bae4e18a2 Fixed bug #70228 (Memleak if return in finally block) 2016-06-08 00:23:33 +03:00
Dmitry Stogov
421843977f Fixed bug #71266 (Missing separation of properties HT in foreach etc). 2016-06-07 23:18:52 +03:00
Dmitry Stogov
214d4613f5 cleanup 2016-06-07 01:14:53 +03:00