Commit Graph

124815 Commits

Author SHA1 Message Date
Máté Kocsis
a5360e80c2
Add support for final class constants
RFC: https://wiki.php.net/rfc/final_class_const

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2021-07-06 21:42:38 +02:00
Ben Ramsey
c6d4f60827
The master branch is now for 8.1.0beta1 2021-07-06 10:23:32 -05:00
Nikita Popov
f43a19ee94 Slightly clean up reflection constant printing
The basic formatting is always the same, the only thing that
differs is how the value is printed, so don't duplicate the rest.
2021-07-06 16:25:05 +02:00
Nikita Popov
5502910ed8 Fix phar test
Make getCurrentLine() return a string rather than an array.
2021-07-06 14:53:50 +02:00
Nikita Popov
8a67dfd16b Ensure correct return type from SplFileObject::getCurrentLine()
This is necessary to maintain return type consistency once
tentative return types are added.
2021-07-06 14:32:39 +02:00
Nikita Popov
188b1d4c7c SplFileObject::fgetcsv(): Consistently return false on failure
Both the documentation and the stubs state that this method is
supposed to return false on failure. However, if the line read
(rather than the getcsv operation) fails, it would incorrectly
return null instead.
2021-07-06 14:24:26 +02:00
Christoph M. Becker
2ad97f5cbd
Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix new test for PHP 8.0
2021-07-06 13:30:05 +02:00
Christoph M. Becker
52a00fe776
Fix new test for PHP 8.0 2021-07-06 13:27:23 +02:00
Nikita Popov
ac7a28189a Add initialization checks to DirectoryIterator methods 2021-07-06 13:08:53 +02:00
Nikita Popov
e258f13fab Add test for weird fgetcsv behavior
I was trying to figure out when fgetcsv parsing can return false.
Apparently this can only happen if there is an unclosed enclosure
and no terminating newline -- why does the newline matter???
2021-07-06 12:37:22 +02:00
Nikita Popov
076fbd360a Minor fgetcsv cleanup
Reduce some variable scopes.
2021-07-06 12:37:22 +02:00
Nikita Popov
1a81251dbb Use some early returns in spl_directory 2021-07-06 12:37:22 +02:00
Christoph M. Becker
a3abcc063e
Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #81223: flock() only locks first byte of file
2021-07-06 12:03:55 +02:00
Christoph M. Becker
d776413f0b
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #81223: flock() only locks first byte of file
2021-07-06 12:00:09 +02:00
Christoph M. Becker
520c00a5bf
Fix #81223: flock() only locks first byte of file
`flock()` should lock the whole file, like on other systems which use
mandatory locking.  We cannot use `0` like for `flck.l_len`, so we use
the largest number, what is valid according to the documentation:
<https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-lockfileex#remarks>.

Closes GH-7216.
2021-07-06 11:58:02 +02:00
Brent Roose
909e13459c Fix typo "without-pcre-jit" 2021-07-06 11:47:00 +02:00
Nikita Popov
bb97c947e3 Slightly clarify current_zval handling in spl_directory
This used COPY_DEREF in some places where references can't occur.
2021-07-06 11:37:42 +02:00
Máté Kocsis
65b96397b3
Declare tentative return types for ext/intl (#6986) 2021-07-06 10:55:43 +02:00
Nikita Popov
54c4c7d747 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix ArrayObject::exchangeArray() return type
2021-07-06 10:52:46 +02:00
Nikita Popov
bcefc31e4e Fix ArrayObject::exchangeArray() return type
This method cannot return null.
2021-07-06 10:52:08 +02:00
Christoph M. Becker
097cae9d90
Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #74264: grapheme_strrpos() broken for negative offsets
2021-07-05 18:21:29 +02:00
Christoph M. Becker
8071bd2faf
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #74264: grapheme_strrpos() broken for negative offsets
2021-07-05 18:15:24 +02:00
Christoph M. Becker
28c9376306
Fix #74264: grapheme_strrpos() broken for negative offsets
We must not assume that `usearch_last()` gives the proper result for
negative offsets.  Instead we'd need to continue to search backwards
(`usearch_previous`) until we find a proper match.  However, apparently
searching backwards is broken, so we work around by searching forward
from the start of the string until we pass the `offset_pos`, and then
use the previous result.

Closes GH-7189.
2021-07-05 18:11:30 +02:00
Alex Dowad
b626e893ff Fix conversion of ISO-2022-KR text (and add test suite)
- Truncated multi-byte characters are treated as an error
- Truncated or unrecognized escape sequences are treated as an error
- ASCII control characters are not allowed to appear in the middle
  of a multi-byte character
2021-07-05 16:28:16 +02:00
Alex Dowad
658db1f6ea Code cleanup in mbfilter_uhc.c 2021-07-05 16:28:16 +02:00
Alex Dowad
0a8c00755d Fix conversion of EUC-JP-2004 text (and add test suite)
- Truncated multi-byte characters are treated as an error now
- Invalid multi-byte characters are treated as an error rather than
  being quietly swallowed
- ASCII control characters are not allowed to appear in the middle
  of a multi-byte character
2021-07-05 16:28:16 +02:00
George Peter Banyard
069a9fa5e4
Pure Intersection types (#6799)
Implement pure intersection types RFC

RFC: https://wiki.php.net/rfc/pure-intersection-types

Co-authored-by: Nikita Popov <nikic@php.net>
Co-authored-by: Ilija Tovilo <ilutov@php.net>
2021-07-05 14:11:03 +02:00
Nikita Popov
629965c80f Handle promoted exception in int|string type
Fixes oss-fuzz #35790.
2021-07-05 10:48:20 +02:00
Christoph M. Becker
9a42d2b87b
Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix build
2021-07-04 23:15:14 +02:00
Christoph M. Becker
d86c25d88e
Fix build
`accel_system_id` gas been renamed to `zend_system_id`.
2021-07-04 23:13:50 +02:00
Christoph M. Becker
b09134139e
Merge branch 'PHP-8.0'
* PHP-8.0:
  Avoid OOB reads in create_name_with_username()
2021-07-04 22:56:37 +02:00
Christoph M. Becker
948b83d7ea
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Avoid OOB reads in create_name_with_username()
2021-07-04 22:54:48 +02:00
Christoph M. Becker
b1840737e2
Avoid OOB reads in create_name_with_username()
`accel_uname_id` and `zend_system_id` are MD5 buffers which are not
NUL terminated.  Thus, we must not pass them to `snprintf()`.

Closes GH-6968.
2021-07-04 22:51:55 +02:00
Nikita Popov
600dc57f24 Add ext/reflection to execute parser corpus 2021-07-04 12:31:14 +02:00
Anatol Belski
e7123ef569
phar: crc32: Extend and cleanup API for the new bulk crc32 functions
As suggested on the patch discussion, adding init/end macros. Plus,
prefixed the new functions with php_ to avoid possible symbol conflicts.

Signed-off-by: Anatol Belski <ab@php.net>
2021-07-03 21:03:47 +02:00
Ben Morss
fea437af56 Reduce girl.avif by 4x
This will make tests much faster, since one of our tests involves lossless conversion.
2021-07-03 09:41:30 +02:00
Nikita Popov
7bc0dd21c8 Merge branch 'PHP-8.0'
* PHP-8.0:
  Add missing error condition to stream_context_set_option()
2021-07-02 17:56:26 +02:00
Nikita Popov
1b01bf3a95 Add missing error condition to stream_context_set_option()
Previously this caused a null pointer dereference if the value
argument was not provided.
2021-07-02 17:55:31 +02:00
Nikita Popov
f7b1238f13 Handle out of order destruction of RecursiveIteratorIterator 2021-07-02 17:14:00 +02:00
Nikita Popov
29b82695b5 Fix leak of callable error if exception also thrown 2021-07-02 16:33:14 +02:00
Nikita Popov
c2a8934b86 Fix typo in RecursiveIteratorIterator get_gc handler 2021-07-02 16:11:48 +02:00
Nikita Popov
b65380286a Avoid null pointer arithmetic in SplFixedArray
Fixes bug62904.phpt under clang ubsan.
2021-07-02 15:39:22 +02:00
Nikita Popov
52cf7ab8a2 Fix bug #80072: Root live tmpvars after GC
TMPVAR operands are destroyed using zval_ptr_dtor_nogc(), because
they usually cannot contain cycles. However, there are some rare
exceptions where this is possible, e.g. unserialize() return value.
In such cases we rely on the producing code to root the value. If
a GC run occurs between the rooting and consumption of the value,
we would end up leaking it. To avoid this, root all live TMPVAR
values after a GC run.

Closes GH-7210.
2021-07-02 15:28:36 +02:00
Nikita Popov
083d7f5886 Reduce stack usage in php_resolve_path()
tsrm_realpath() internally always allocates a string. If the out
parameter is provided it gets copied there and freed. What we
were doing here was to first copy the path from the allocated
string to a stack buffer, and then copy it from the stack buffer
to a zend_string. We might as well save one copy and one buffer.
2021-07-02 11:45:16 +02:00
Nikita Popov
3321440166 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix return value of wrong fucntion by-ref assign
2021-07-02 11:18:46 +02:00
Nikita Popov
6617829f1b Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix return value of wrong fucntion by-ref assign
2021-07-02 11:18:09 +02:00
Nikita Popov
96bf925cde Fix return value of wrong fucntion by-ref assign
We should be using the result of zend_assign_to_variable() here,
which will deref prior to potential freeing.

Fixes oss-fuzz #29899.
2021-07-02 11:15:31 +02:00
Nikita Popov
53fba3a13d Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80173
2021-07-02 10:08:57 +02:00
Nikita Popov
4e66e6a73a Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fixed bug #80173
2021-07-02 10:08:40 +02:00
Nikita Popov
bdc60fa7da Fixed bug #80173
The analysis in the bug report wasn't correct (at least not in
this case -- there may still be a more general problem here),
the issue was that write_property returned the original variable_ptr
rather than the zend_assign_to_variable() return value, which will
DEREF the variable before overwriting it.
2021-07-02 10:07:40 +02:00