Commit Graph

13858 Commits

Author SHA1 Message Date
Nikita Popov
f2e374c881 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix bug #81265: getimagesize returns 0 for 256px ICO images
2021-07-16 10:07:35 +02:00
Nikita Popov
12a858ac95 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix bug #81265: getimagesize returns 0 for 256px ICO images
2021-07-16 10:07:26 +02:00
George Dietrich
8f97f82e35 Fix bug #81265: getimagesize returns 0 for 256px ICO images
Set ICO height/width to 256 if 0.
2021-07-16 10:05:58 +02:00
George Peter Banyard
0ba155cd57 Make syslog() binary safe
Closes GH-7245

Co-authored-by: Nikita Popov <nikita.ppv@googlemail.com>
2021-07-15 19:08:26 +02:00
Christoph M. Becker
6dc20e1a24
Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #72146: Integer overflow on substr_replace
2021-07-15 12:57:24 +02:00
Christoph M. Becker
c0a1ef3e32
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #72146: Integer overflow on substr_replace
2021-07-15 12:56:12 +02:00
Christoph M. Becker
33f8dfb15a
Fix #72146: Integer overflow on substr_replace
Adding two `zend_long`s may overflow, and casting `size_t` to
`zend_long` may truncate; we can avoid this here by enforcing unsigned
arithmetic.

Closes GH-7240.
2021-07-15 12:54:28 +02:00
George Peter Banyard
10f416f5c2 Use standard bool type instead of bool_int 2021-07-15 10:40:36 +02:00
Nikita Popov
4b3615a33f Deprecate strftime() and gmstrftime()
These are deprecated in favor of date()/DateTime::format() (for
locale-indendent formatting) and IntlDateFormatter::format()
(for locale-dependent formatting).

Part of https://wiki.php.net/rfc/deprecations_php_8_1.
2021-07-14 09:38:43 +02:00
Nikita Popov
67776308e2 Fix php_user_filter::filter() return value
We specify that this needs to return an int, so do so.
PSFS_ERR_FATAL has value 0 which is what the null value previously
returned would be interpreted as.
2021-07-13 11:50:07 +02:00
David CARLIER
16072074f3
Fix pointer constness warning in crc32 module on arm64 (#7225) 2021-07-09 15:29:36 +02:00
Nikita Popov
232aa34b9f Deprecate auto_detect_line_endings
Part of https://wiki.php.net/rfc/deprecations_php_8_1.
2021-07-09 10:05:57 +02:00
Nikita Popov
bed7139375 Deprecate strptime()
Use date_parse_from_format() or IntlDateFormatter::parse() instead.

Part of https://wiki.php.net/rfc/deprecations_php_8_1.
2021-07-09 10:03:45 +02:00
Nikita Popov
92f6e21523 Deprecate FILE_BINARY and FILE_TEXT constants
These constants have no effect.

Part of https://wiki.php.net/rfc/deprecations_php_8_1.
2021-07-08 15:34:51 +02:00
Nikita Popov
dcc8463ae5 Deprecate IAP functions on objects
Deprecate use of key(), current(), next(), prev(), reset() and
end() on objects. Cast the object to array first.

Part of https://wiki.php.net/rfc/deprecations_php_8_1.
2021-07-08 15:28:33 +02:00
Ben Morss
cee33bab16
AVIF support for getimagesize() and imagecreatefromstring()
Thanks to Joe Drago for help with the AVIF detection code.

Co-authored-by: Nikita Popov <nikita.ppv@googlemail.com>
Co-authored-by: Christoph M. Becker <cmbecker69@gmx.de>

Closes GH-7091.
2021-07-07 00:02:57 +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
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
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
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
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
Patrick Allaert
ac18dd0dc7 Prefer EXPECT over EXPECTF 2021-06-29 17:13:02 +02:00
Patrick Allaert
aff365871a Fixed some spaces used instead of tabs 2021-06-29 11:30:26 +02:00
Tyson Andre
e00b3ec6ae
Fix false positive recursion warning for var_export of enums (#7201) 2021-06-26 15:33:39 -04:00
Patrick Allaert
182e3ac0c3 Removing obsolete tests
Those were testing the `p` parameter for ZPP.
2021-06-23 19:06:50 +02:00
Patrick Allaert
3221a4cb4c Remove " " being considered as an invalid filename for is_file()
Some builds fail because of it, last one to date is: https://travis-ci.com/github/php/php-src/jobs/517817543
2021-06-23 19:06:50 +02:00
Remi Collet
b83bfb2c54
make new API public (#7185) 2021-06-22 18:42:43 +02:00
Benjamin Eberlei
0ca5ab4fa5
Add host for php_network_getaddresses getaddrinfo failed error message. (#7181) 2021-06-22 17:18:09 +02:00
jianxind
28a1a6be08
phar: use crc32 bulk method instead. (#6099)
phar: use crc32 bulk method instead.

Benefit from the hardware crc32 computing.

Signed-off-by: Frank Du <frank.du@intel.com>
2021-06-19 22:21:21 +02:00
George Peter Banyard
351629ae15
Fix test
This seems to only be incorrect for the 8.0 branch
2021-06-18 18:09:27 +01:00
Joe Watkins
fba439196e
Fix bug #81163 __sleep allowed to return non-array 2021-06-18 11:23:01 +02:00
Joe Watkins
7bf930d014
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix bug #81163 indirect vars in __sleep
2021-06-18 11:17:03 +02:00
Joe Watkins
bc59b046c6
Fix bug #81163 indirect vars in __sleep 2021-06-18 11:16:26 +02:00
Christoph M. Becker
22d700b66a
Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix test in case fallocate(1) is available, but fails
2021-06-17 19:08:58 +02:00
Christoph M. Becker
3374adcd14
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix test in case fallocate(1) is available, but fails
2021-06-17 19:06:18 +02:00
Christoph M. Becker
99e7c5cea8
Fix test in case fallocate(1) is available, but fails
That happens on Travis s390x for whatever reasons.  Thus, instead of
checking for `fallocate -h`, we attempt the real allocation and skip if
that fails.
2021-06-17 19:05:07 +02:00
Christoph M. Becker
83517340f6
Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #81145: copy() and stream_copy_to_stream() fail for +4GB files
2021-06-17 13:18:59 +02:00
Christoph M. Becker
8daed6d0f2
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #81145: copy() and stream_copy_to_stream() fail for +4GB files
2021-06-17 13:16:30 +02:00
Christoph M. Becker
2555efadbc
Fix #81145: copy() and stream_copy_to_stream() fail for +4GB files
When mapping the file, we need to pass the proper `dwFileOffsetHigh`
instead of `0`.

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>

Closes GH-7158.
2021-06-17 13:13:47 +02:00
Nikita Popov
892421c9a8 Make some zend_test dependencies explicit
Rather than checking that specific functions exist.
2021-06-14 15:40:34 +02:00
Joe Watkins
72c0deb400
Revert "hrtime implementation update for Mac"
This reverts commit a3e55286a6.

    This commit broke the build for OSX before Sierra.

    The apple documentation states the equivalent uses raw uptime, and
    the source code of the non portable function says raw uptime would
    call the same routine we were calling before this commit.

    Since the correct version of this commit - according to docs -
    would bring no value whatsoever, and this version breaks the build
    there doesn't seem any sense in making this change.
2021-06-14 14:27:35 +02:00
Nikita Popov
b6fa386749 Regenerate arginfo file 2021-06-14 10:59:18 +02:00
Nikita Popov
39131219e8
Migrate more SKIPIF -> EXTENSIONS (#7139)
This is a mix of more automated and manual migration. It should remove all applicable extension_loaded() checks outside of skipif.inc files.
2021-06-11 12:58:44 +02:00
Nikita Popov
7485978339
Migrate SKIPIF -> EXTENSIONS (#7138)
This is an automated migration of most SKIPIF extension_loaded checks.
2021-06-11 11:57:42 +02:00
Nikita Popov
f172bb30be Regenerate stubs 2021-06-11 10:35:21 +02:00
Joe Watkins
ec9ce49c8e
Merge branch 'PHP-8.0'
* PHP-8.0:
  fix bad refactor of #7136
2021-06-11 09:34:03 +02:00
Joe Watkins
b10bcb4faa
fix bad refactor of #7136 2021-06-11 09:33:55 +02:00
Joe Watkins
9068b27974
Merge branch 'PHP-8.0'
* PHP-8.0:
  Enable net_get_interfaces on IBM i PASE
2021-06-11 09:14:17 +02:00
Calvin Buckley
4f51a11a84
Enable net_get_interfaces on IBM i PASE
On IBM i, getifaddrs is available renamed as Qp2getifaddrs; freeifaddrs
and struct ifaddr follow a similar fate. I assume this is in case AIX
decides to add it (as if). As such, just use the same implementation,
but rename the standard ones to the IBM i definitions and include its
header.
2021-06-11 09:12:49 +02:00
Ayesh Karunaratne
b8e380ab09 Update deprecation message for incompatible float to int conversion
Updates the deprecation message for implicit incompatible float to int conversion from:

```
Implicit conversion from non-compatible float %.*H to int in %s on line %d
```

to

```
Implicit conversion from float %.*H to int loses precision in %s on line %d
```

Related: #6661
2021-06-07 14:36:11 +02:00
David Carlier
67b0e435f3 crc32 feature detection from auxiliary vectors on FreeBSD 2021-06-07 14:33:35 +02:00
Christoph M. Becker
8a8e307cd5
Mark slow tests
Each of these tests took more than ten seconds on a recent AppVeyor CI
run; that appears to qualify them to be marked as slow tests.

Closes GH-7077.
2021-06-03 15:14:08 +02:00
George Peter Banyard
b6958bb847
Implement "Deprecate implicit non-integer-compatible float to int conversions" RFC. (#6661)
RFC: https://wiki.php.net/rfc/implicit-float-int-deprecate

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2021-05-31 15:48:45 +01:00
Peter van Dommelen
3a4ea6cb91 Don't automatically adjust memory_limit to 2M
As PHP has a minimum memory usage of 2M (size of allocator chunk),
setting a limit below that value is not meaningful and will be
automatically rounded up to the chunk size. Rather than doing this
silently, show the newly introduced error message.

The memory limit had to be increased to 2M for a number of tests.

tests/lang/bug45392 has been marked as XFAIL. This old bugfix is
not working as intended. The memory limit in main's `PG(memory_limit)`
differs from the one in zend_alloc. In zend_alloc the `AG(mm_heap)->limit`
is defined as `max(passed_value, ZEND_MM_CHUNK_SIZE)`. The check made in
an unclean shutdown will never be true unless the memory limit is lower
than ZEND_MM_CHUNK_SIZE, which happened to be the case in the test.
https://bugs.php.net/bug.php?id=45392
fcc0fdd125
2021-05-31 15:42:10 +02:00
Christoph M. Becker
c8244dd989
Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix typo in test case (doe → die)
2021-05-29 15:40:15 +02:00
Christoph M. Becker
140eca603c
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix typo in test case (doe → die)
2021-05-29 15:39:17 +02:00
Christoph M. Becker
4ab434fa0e
Fix typo in test case (doe → die) 2021-05-29 15:36:40 +02:00
Anatol Belski
56c16334e5
ext: Cleanup some dead assignments
Signed-off-by: Anatol Belski <ab@php.net>
2021-05-29 13:03:32 +02:00
Nikita Popov
ea256a218b Add %0 format to run-tests.php
This format matches against null bytes, and prevents the test
expectation from being interpreted as binary data.

bless_tests.php will automatically replace \0 with %0 as well.
2021-05-29 11:33:13 +02:00
Máté Kocsis
48981f4f1e
Declare tentative return types for ext/standard (#7065) 2021-05-28 15:46:04 +02:00
twosee
2389ac229f
Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix argument index in stream_select()
2021-05-28 17:41:52 +08:00
twosee
b751c24e23
Fix argument index in stream_select()
Closes GH-7067.
2021-05-28 17:37:51 +08:00
Máté Kocsis
5beba0b038
Declare tentative return types for ext/json (#7051) 2021-05-27 10:47:15 +02:00
Máté Kocsis
b4b848bfa7
Fix the signature of ini_alter()
It should be the same as ini_set()
2021-05-26 12:32:38 +02:00
David CARLIER
90b843beb6
Add FreeBSD to CI (#6974)
This is using Cirrus, as none of the CI providers we already use support FreeBSD.
2021-05-21 12:00:46 +02:00
Nikita Popov
f9990009c8 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix handling of open_basedir that contains cwd
2021-05-20 09:53:57 +02:00
Nikita Popov
ef59d09af0 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix handling of open_basedir that contains cwd
2021-05-20 09:53:25 +02:00
Nikita Popov
ee7a8acde9 Fix handling of open_basedir that contains cwd
While resolving the path, the last step will reduce it down to ""
(an empty string) and realpath() will resolve this to getcwd().
If open_basedir contains the CWD, then that means open_basedir
will be bypassed for paths that don't have any components that
exist (if one of the components exists, then we abort the realpath
loop at that point).

Closes GH-7015.
2021-05-20 09:52:21 +02:00
Nikita Popov
11bf5ccf62 Set default_socket_timeout in test
If the read is not refused outright, this will timeout, and we
don't want to wait 60s for that.
2021-05-19 15:29:38 +02:00
Nikita Popov
23c90dcdfb Report error from socket read on timeout
A timeout is not considered a transient error (at the socket layer),
and should return -1 rather than 0.
2021-05-19 15:29:16 +02:00
Nikita Popov
4c15dffe3a Reduce timeout in FTP PASV connection failure test
If the connection times out rather than being refused outright,
don't wait the full 60 seconds that are used by default. If this
happens, the error message will also be different.
2021-05-19 15:08:40 +02:00
Christoph M. Becker
adb0e4f18d
Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #81048: phpinfo(INFO_VARIABLES) "Array to string conversion"
2021-05-19 14:10:02 +02:00
Christoph M. Becker
5dfdd694e7
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #81048: phpinfo(INFO_VARIABLES) "Array to string conversion"
2021-05-19 14:09:21 +02:00
Christoph M. Becker
36b9bdeeec
Fix #81048: phpinfo(INFO_VARIABLES) "Array to string conversion"
Now that we properly dereference references of the superglobals. we
also need to dereference contained references to avoid to string
conversion.

Closes GH-7014.
2021-05-19 14:07:15 +02:00
Nikita Popov
0fd796133a Drop test that is always skipped
This test is skipped unconditionally, so I don't think there's
much point in keeping it.
2021-05-19 13:02:30 +02:00
Nikita Popov
2c6b85f6fe Remove bug49936.phpt
In the meantime, additional tests for ftp:// with opendir() have
been added, which tests actual behavior against a server. This one
just uses localhost (without running a server), which can make the
test very slow on systems that don't refuse the connection outright.
2021-05-19 12:14:16 +02:00
Nikita Popov
976dd997de Fix open_basedir tests when running from /tmp
If our cwd is in /tmp, these tests would fail. Use a directory
name that is less likely to clash.
2021-05-19 10:36:44 +02:00
Nikita Popov
06ea1a2502 Skip some strptime() tests on FreeBSD
tm_wday/tm_yday generally have unreliable behavior. What we're
testing is how glibc works.
2021-05-18 19:33:57 +02:00
Nikita Popov
11648c00e9 Don't include object hash in SplObjectStorage debug dump
The object hash is not particularly useful (anymore) and just
clutters the output. It encodes the same information as the
object ID, which is already part of the output.
2021-05-18 17:20:20 +02:00
George Peter Banyard
db1bde73cf
Use equals OR equal instead of >= && <=
For only two values this is clearer
2021-05-18 15:08:12 +01:00
George Peter Banyard
e7135cb817
Use zend_string_equals_* API in a couple of more place
Closes GH-6979
2021-05-14 13:45:17 +01:00
George Peter Banyard
aca6aefd85
Remove 'register' type qualifier (#6980)
The compiler should be smart enough to optimize this on its own
2021-05-14 13:38:01 +01:00
K
21422e8536
Optimize unpack() for named fields (#6958)
Create name using either zend_init_string_fast (no repetitions) or by concatenating the name with zend_print_ulong_to_buf. This is much more efficient than using snprintf. We also avoid repeated strlen() calculations.
2021-05-14 11:32:46 +02:00
George Peter Banyard
b7356692f6
Specify function pointer signature for scanf implementation
Fix [-Wstrict-prototypes] warnings in standard/scanf.c
2021-05-12 18:58:44 +01:00
George Peter Banyard
c40231afbf
Mark various functions with void arguments.
This fixes a bunch of [-Wstrict-prototypes] warning,
because in C func() and func(void) have different semantics.
2021-05-12 14:55:53 +01:00
dwgebler
f5139878f9
Check parameters on compact() and throw warning if not string or array of strings (#6921)
compact() is documented (https://www.php.net/manual/en/function.compact) as a variadic function accepting parameters which are strings or arrays of strings referencing defined symbols.

In actuality, passing nonsense parameters e.g. compact(true, 42) merely returns an empty array. I propose throwing a warning in these cases, to prevent silent bugs.
2021-05-11 09:36:12 +02:00
Michael Voříšek
3ccc0409ce Remove no longer used "log_errors_max_len" ini directive (#6838)
This is a re-application of the original match against master.
The patch was originally applied to master, then reverted from
there, incorrectly applied to PHP-8.0, reverted from there due
to ABI break, and now lands on master again. We can only hope
that it does not get reverted again ;)
2021-05-10 19:26:33 +02:00
Nikita Popov
4f46bec5d4 Initialize zpp varargs variables
These are not initialized if no args are passed.
2021-05-10 19:19:26 +02:00
Aaron Piotrowski
39fa55a4c9
Switch register_tick_function back to zend_parse_parameters
No reason to use fast ZPP in register_tick_function, so let’s keep the binary size down just a bit.
2021-05-10 10:17:29 -05:00
George Peter Banyard
a9695cc615
Refactor register shutdown function mechanism
Use FCI/FCC structure instead of custom implementation which does the same.
This also fixes the "bug" which prevented static methods from being shutdown functions.

Closes GH-5829

Co-authored-by: Aaron Piotrowski <aaron@trowski.com>
2021-05-10 15:54:59 +01:00
Aaron Piotrowski
66bfad57de
Remove unnecessay NULL
Z_PARAM_FUNC already sets params to NULL.
2021-05-09 14:55:05 -05:00
Aaron Piotrowski
0189585c9e
Fix tick function with arguments
Tick function arguments need to be copied to fci params.
2021-05-09 14:08:20 -05:00
Aaron Piotrowski
7ec048f96d
Do not free tick function entry
This memory is freed by zend_llist.
2021-05-09 11:44:32 -05:00
Nikita Popov
090627048c Revert "Remove no longer used "log_errors_max_len" ini directive (#6838)"
This reverts commit d2d227e547.

This is an ABI break.
2021-05-08 20:54:53 +02:00
Ben Ramsey
b5d5d06ff3
Revert "Remove no longer used "log_errors_max_len" ini directive (#6838)"
This reverts commit cc2c810dcf.
2021-05-08 13:23:58 -05:00
Michael Voříšek
d2d227e547
Remove no longer used "log_errors_max_len" ini directive (#6838) 2021-05-08 13:05:13 -05:00
Remi Collet
99d67d121a
use getnameinfo instead of gethostbyaddr 2021-05-08 14:52:06 +02:00
George Peter Banyard
05e6f3ebde
Refactor register_tick_function mechanism (#5828) 2021-05-08 10:09:09 +01:00
Michael Voříšek
cc2c810dcf
Remove no longer used "log_errors_max_len" ini directive (#6838) 2021-05-07 19:07:35 -05:00
Nikita Popov
32b107e6a6 Use smart_str_extend() instead of smart_str_alloc()
These usages were re-implementing the exact functionality of
smart_str_extend().
2021-05-07 16:42:17 +02:00
Nikita Popov
072c50fc77 Merge branch 'PHP-8.0'
* PHP-8.0:
  Update msan job to Ubuntu 20.04
  Skip some tests under msan
2021-05-07 16:28:57 +02:00
Nikita Popov
af948ae24c Skip some tests under msan
These test functions which don't have msan interceptors. This
results in false positives running msan on ubuntu 20.04.
2021-05-07 16:26:49 +02:00
Máté Kocsis
4ece535f19
Merge branch 'PHP-8.0'
* Fix return type of php_user_filter::onCreate()
* Fix return type of mysqli::init()
* Fix return type of UConverter::fromUCallback() and UConverter::toUCallback()
2021-05-07 15:23:28 +02:00
Máté Kocsis
a3c38c2596
Fix return type of php_user_filter::onCreate() 2021-05-07 15:21:11 +02:00
Nikita Popov
4baf340c39 Merge branch 'PHP-8.0'
* PHP-8.0:
  Remove getservbyname() variation tests
  Use SOL_TCP instead of getprotobyname() in tests
2021-05-07 14:56:13 +02:00
Nikita Popov
12118d592a Remove getservbyname() variation tests
These are zpp variations, which we no longer test.
2021-05-07 14:55:27 +02:00
Nikita Popov
9eb295fc4c Fix -Wreturn-local-addr warning
zend_string_dup() can return the original string if it is interned.
Of course, the string can't be interned here, but GCC doesn't know
that and throws a warning in release builds.

Replace zend_string_dup() (which is a bad API anyway) with a direct
call to zend_string_init(), which makes it more obvious that the
original alloca'd string cannot be reused.
2021-05-07 12:11:52 +02:00
K
efe79e0de6
Simplify unpack logic (#6908)
- move endiannes check to compile time
- remove php_unpack function
- the compiler take care of sign extension
2021-05-06 15:20:05 +02:00
Remi Collet
f9547f2b47
get rid of inet_aton and inet_ntoa use inet_ntop iand inet_pton where available standardize buffer size 2021-05-06 13:39:58 +02:00
KsaR
01b3fc03c3
Update http->https in license (#6945)
1. Update: http://www.php.net/license/3_01.txt to https, as there is anyway server header "Location:" to https.
2. Update few license 3.0 to 3.01 as 3.0 states "php 5.1.1, 4.1.1, and earlier".
3. In some license comments is "at through the world-wide-web" while most is without "at", so deleted.
4. fixed indentation in some files before |
2021-05-06 12:16:35 +02:00
Nikita Popov
3e6b447979 Partially deprecate Serializable
If Serializable is implemented, require that __serialize() and
__unserialize() are implemented as well, else issue a deprecation
warning.

Also deprecate use of PDO::FETCH_SERIALIZE.

RFC: https://wiki.php.net/rfc/phase_out_serializable

Closes GH-6494.
2021-04-28 16:55:14 +02:00
Nikita Popov
fd1d5ec2b4 Add ZEND_CLASS_CONST_FLAGS() macro
And drop Z_ACCESS_FLAGS(). We no longer store *only* access flags
in these.
2021-04-28 14:51:54 +02:00
Nikita Popov
e8ef923dd6 Merge branch 'PHP-8.0'
* PHP-8.0:
  Remove assert_options() return value info
2021-04-28 11:06:54 +02:00
Nikita Popov
76d1120a48 Remove assert_options() return value info
The ASSERT_CALLBACK value is not validated at all -- it's possible
to set it to an arbitrary value. As such, the function can also
return any value or type (even without outright abuse, the opcache
func info was wrong in that the return can be rcn, and the array
can be array_of_ref).
2021-04-28 11:05:05 +02:00
Nikita Popov
dc7030300c Use interned strings for error_get_last()
We have known strings for all the array keys, use them.
2021-04-23 11:05:14 +02:00
Nikita Popov
b66eb866c9 Convert last_error_file to zend_string 2021-04-23 11:05:14 +02:00
Máté Kocsis
30a082cb16
Make some exception properties typed
Closes GH-6891
2021-04-22 10:22:50 +02:00
Niklas Keller
59d5b3dd51
Accept null for microseconds argument in stream_select() (#6879)
The deprecation of passing null is thrown otherwise.

If the timeout is calculated conditionally before calling stream_select(), passing to avoid the deprecation seems unreasonable, example:

7d4bbc6e0b/lib/Loop/NativeDriver.php (L286)

Also enforce that if $seconds is null, then $microseconds should be null as well. However 0 is still accepted (with deprecation) for backwards compatibility.
2021-04-22 10:09:55 +02:00
Máté Kocsis
8c97fc88f3 Use typed properties in php_user_filter 2021-04-20 14:45:42 +02:00
Christoph M. Becker
84a3f59d45
Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix expected error message
2021-04-19 18:49:55 +02:00
Christoph M. Becker
8a7b786b7f
Fix expected error message
These are slightly changed as of PHP 8.0.0.
2021-04-19 18:48:44 +02:00
Christoph M. Becker
c8a966a9ae
Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #80960: opendir() warning wrong info when failed on Windows
2021-04-19 16:18:03 +02:00
Christoph M. Becker
cb262cd974
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #80960: opendir() warning wrong info when failed on Windows
2021-04-19 16:17:01 +02:00
Christoph M. Becker
ea3c992bff
Fix #80960: opendir() warning wrong info when failed on Windows
Firstly, we must not forget to set appropriate error codes for "manual"
checks in `virtual_file_ex()`.

Secondly, we must not call `php_error_docref2()` for warnings regarding
unary functions; thus, we introduce `php_win32_docref1_from_error()`.

Closes GH-6872.
2021-04-19 16:12:22 +02:00
Dmitry Stogov
f1ad9199ef Better support for cross-compilation 2021-04-16 17:28:54 +03:00
twosee
0236bbc777
Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80958
2021-04-16 16:19:43 +08:00
twosee
ecc4bf14f0
Fixed bug #80958
Missing check after zval_try_get_string().

Closes GH-6871.
2021-04-16 16:17:37 +08:00
K
438189531c Speed up array_column for consecutive objects of the same class 2021-04-16 09:52:57 +02:00
Nikita Popov
25f23781a8 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix return-by-ref from array_reduce callback
2021-04-15 12:32:41 +02:00
Nikita Popov
f40c8fdf67 Fix return-by-ref from array_reduce callback
Fixes oss-fuzz #32990.
2021-04-15 12:32:05 +02:00
twosee
1215563288
Micro optimizations for http_fopen_wrapper.c (#6864) 2021-04-15 16:34:17 +08:00
David Gebler
cbcfd86026 Add fsync() and fdatasync() functions
fsync is a straightforward wrapper around the same C function
(implemented on Windows API as _commit() with identical signature).

From the man pages:

    fsync() transfers ("flushes") all modified in-core data of (i.e.,
    modified buffer cache pages for) the file referred to by the file
    descriptor fd to the disk device (or other permanent storage
    device) so that all changed information can be retrieved even if
    the system crashes or is rebooted.  This includes writing through
    or flushing a disk cache if present.  The call blocks until the
    device reports that the transfer has completed.

RFC: https://wiki.php.net/rfc/fsync_function

Closes GH-6650.
2021-04-13 16:09:22 +02:00
Nikita Popov
02557e62c9 Merge branch 'PHP-8.0'
* PHP-8.0:
  change PHP_EGG_LOGO_DATA_URI to php8 elePHPant called InPHPinity
2021-04-13 11:49:58 +02:00
Noriko Yamamoto
2ebd1c4e86 change PHP_EGG_LOGO_DATA_URI to php8 elePHPant called InPHPinity
Closes GH-6827.
2021-04-13 11:49:42 +02:00
twosee
d5456baf52
Use zend_throw_unwind_exit() for assert.bail (#6826)
We can use unwind_exit instead of the evil zend_bailout without breaking the original behavior in this way because the original zend_bailout will longjmp out of the executor, so the exception will never be caught and it always triggers the E_ERROR here.
2021-04-13 15:23:36 +08:00
Nikita Popov
dae23ab723 Merge branch 'PHP-8.0'
* PHP-8.0:
  Remove the "getdir" function which was introduced accidentally
2021-04-12 11:14:28 +02:00
Rowan Tommins
4e98e65d53 Remove the "getdir" function which was introduced accidentally
The actual name of this function is dir(), but ever since it was
introduced in PHP 3, its internal name was "getdir", leading to it
being mistaken for an alias. This went unnoticed until the switch
to stubs for generating arginfo, at which point getdir() became a
real but undocumented function.

Fixes bug #80914.

Closes GH-6855.
2021-04-12 11:13:57 +02:00
Nikita Popov
4ce5d2ea88 Add known strings for jit autoglobals
We always create interned strings for all autoglobals anyway, so
we might as well add known strings to make them more widely usable.
2021-04-09 15:37:59 +02:00
Nikita Popov
24969b7cd0 Fix incorrect --CREDITS-- section 2021-04-09 12:40:04 +02:00
Dmitry Stogov
f681c4a775 Use Fast Class Cache to speedup object unserialization 2021-04-09 11:36:13 +03:00
George Peter Banyard
09efad615b
Use zend_string_equals_(literal_)ci() API more often
Also drive-by usage of zend_ini_parse_bool()

Closes GH-6844
2021-04-09 02:34:50 +01:00
Dmitry Stogov
f191e4f257 Avoid destructor call for LONG keys 2021-04-09 00:49:27 +03:00
Dmitry Stogov
556d752667 Prevent call of var_push_dtor_value() on hot path.
When serialising object properties, they are oftet may override the
default values, however default values are most often scalars, interned
strings or immutable arrays.
2021-04-09 00:40:17 +03:00
Dmitry Stogov
b3e59dc16f unserialize() optimization 2021-04-07 15:24:53 +03:00
George Peter Banyard
5caaf40b43
Introduce pseudo-keyword ZEND_FALLTHROUGH
And use it instead of comments
2021-04-07 00:46:29 +01:00
Dmitry Stogov
a13a1be734 Use ZEND_HASH_FILL_* API for explode() 2021-04-06 16:57:02 +03:00
Dmitry Stogov
46865392fe Attempt to fix ext/spl/tests/bug67359.phpt broken by f323baa845 2021-04-02 19:09:29 +03:00
Dmitry Stogov
f323baa845 Reduce number of stat() calls 2021-04-02 13:39:12 +03:00
Dmitry Stogov
84a843dff6 Use better function 2021-03-30 20:20:54 +03:00
Christoph M. Becker
90da9bf53b
Merge branch 'PHP-8.0'
* PHP-8.0:
  Handle reference zvals when outputting superglobals in phpinfo()

Signed-off-by: Christoph M. Becker <cmbecker69@gmx.de>
2021-03-30 13:55:36 +02:00
Christoph M. Becker
443478109b
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Handle reference zvals when outputting superglobals in phpinfo()

Signed-off-by: Christoph M. Becker <cmbecker69@gmx.de>
2021-03-30 13:52:38 +02:00
Rowan Tommins
206fd35a98
Handle reference zvals when outputting superglobals in phpinfo()
Fixes <https://bugs.php.net/80915>.

Closes GH-80915.

Signed-off-by: Christoph M. Becker <cmbecker69@gmx.de>
2021-03-30 13:49:22 +02:00
Nikita Popov
202a701a4e Merge branch 'PHP-8.0'
* PHP-8.0:
  Remove zero size special case for copy_to_stream
2021-03-29 15:22:50 +02:00
Nikita Popov
b95b553489 Remove zero size special case for copy_to_stream
This doesn't seem to serve a purpose anymore. Stats are expensive,
so doing an unnecessary stat just to short-circuit the zero size
case is rather dubious. It can also break with stream wrappers
that return inaccurate sizes (symfony/symfony#40574) and probably
can also break with stream filters.

Drop the special case and adjust code to make it more obvious that
it will still be handled correctly.

Closes GH-6807.
2021-03-29 15:21:59 +02:00
George Peter Banyard
8560d168d3
Align types with the output of zend_hash_num_elements() 2021-03-29 14:20:22 +01:00
Cameron Hall
5b29eba7ca Fix #42357: fputcsv() has an optional parameter for line endings
fputcsv does not terminate lines correctly as per RFC 41801[1]. After adding a new parameter fputcsv may now use a user defined line ending,. In order to maintain backwards compatibility fputcsv() still terminates lines with "\n" by default.

Also fixes: #46367[2], #62770[3]
Ref: #42357[4]

[1] <https://tools.ietf.org/html/rfc4180>
[2] <https://bugs.php.net/bug.php?id=46367>
[3] <https://bugs.php.net/bug.php?id=62770>
[4] <https://bugs.php.net/bug.php?id=42357>
2021-03-29 13:34:38 +01:00
Dmitry Stogov
550a662f67 strtr() optimization 2021-03-22 17:37:11 +03:00
Ilija Tovilo
269c8dac1d
Implement enums
RFC: https://wiki.php.net/rfc/enumerations

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>

Closes GH-6489.
2021-03-17 19:08:03 +01:00
George Peter Banyard
a6fc427b8c Use zend_string_equals() API instead of strcmp() in various places
Closes GH-6784
2021-03-17 16:36:23 +00:00
Dmitry Stogov
c732ab400a Change Zend Stream API to use zend_string* instead of char*.
This allows to eliminate re-calculation of string lenght and hash value.
See the detailed list of changes in UPGRADING.INTERNALS.
2021-03-16 20:31:36 +03:00
Nikita Popov
4f750f7171 Revert "Remove some unnecessary explicit header dependencies"
This reverts commit c386b1fb17.

It looks like at least some of these might be needed for ordering
in a clean build?
2021-03-16 14:22:25 +01:00
Nikita Popov
c386b1fb17 Remove some unnecessary explicit header dependencies
These are now automatically tracked by the build system.
2021-03-16 13:02:23 +01:00
Christoph M. Becker
8d58504035 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #80838: HTTP wrapper waits for HTTP 1 response after HTTP 101
2021-03-08 14:52:45 +01:00
Christoph M. Becker
3880b8785b Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #80838: HTTP wrapper waits for HTTP 1 response after HTTP 101
2021-03-08 14:51:45 +01:00
manuel
5787f91c55 Fix #80838: HTTP wrapper waits for HTTP 1 response after HTTP 101
Don't wait for further responses after a HTTP 101 (Switching Protocols) response

Closes GH-6730.
2021-03-08 14:36:31 +01:00
Nikita Popov
500b4b4945 Explicitly print reference wrappers in debug_zval_dump()
Closes GH-6750.
2021-03-04 10:11:37 +01:00
Dmitry Stogov
d02734f05e Loop invariant code motion 2021-03-04 02:10:10 +03:00
Christoph M. Becker
2dc2436e08 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix test wrt. server.inc changes
2021-03-03 12:05:03 +01:00
Christoph M. Becker
303a4ae44a Fix test wrt. server.inc changes 2021-03-03 12:04:06 +01:00
Christoph M. Becker
8162abeb17 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #78719: http wrapper silently ignores long Location headers
2021-03-03 10:48:43 +01:00
Christoph M. Becker
90b24401d6 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #78719: http wrapper silently ignores long Location headers
2021-03-03 10:47:51 +01:00
Christoph M. Becker
51e2015af3 Fix #78719: http wrapper silently ignores long Location headers
When opening HTTP streams, and reading the headers, we currently
discard header lines longer than `HTTP_HEADER_BLOCK_SIZE` (1024 bytes).
While this is not generally forbidden by RFC 7230, section 3.2.5, it
is not generally allowed either, since that may change the "message
framing or response semantics".

We thus fix this by allowing arbitrarily long header lines.

Closes GH-6720.
2021-03-03 10:45:25 +01:00
Christoph M. Becker
87a5a0e2cb Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #80751: Comma in recipient name breaks email delivery
2021-03-01 18:50:58 +01:00
Christoph M. Becker
37c9728615 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #80751: Comma in recipient name breaks email delivery
2021-03-01 18:50:11 +01:00
Christoph M. Becker
71297a254b Fix #80751: Comma in recipient name breaks email delivery
So far, `SendText()` simply separates potential email address lists at
any comma, disregarding that commas inside a quoted-string do not
delimit addresses.  We fix that by introducing an own variant of
`strtok_r()` which caters to quoted-strings.

We also make `FormatEmailAddress()` aware of quoted strings.

We do not cater to email address comments, and potentially other quirks
of RFC 5322 email addresses, but catering to quoted-strings is supposed
to solve almost all practical use cases.

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>

Closes GH-6735.
2021-03-01 18:46:21 +01:00
Tyson Andre
b4fbf1d381 Optimize serializing class names
Because of the memcpy, compilers can't infer that ZSTR_LEN (i.e. class_name->len)
did not change, so they copy it out of memory into a register for the last two
accesses.
php_var_serialize_string already does something similar.

Closes GH-6734
2021-03-01 09:41:13 -05:00
Dmitry Stogov
fa14eedbea Optimized object serialization without rebulding properties HashTable 2021-03-01 16:10:56 +03:00
Dmitry Stogov
56afe2f230 Incomplete class may have only single "MAGIC_MEMBER" 2021-03-01 14:53:30 +03:00
Dmitry Stogov
72c3ededed Change the order of properties used for var_dump(), serialize(), comparison, etc.
Now properties are ordered according to their layout in zend_object structure.
2021-03-01 13:29:49 +03:00
Dmitry Stogov
6c5942f835 serialize() optimization 2021-02-26 13:30:19 +03:00
Dmitry Stogov
13e4ce386b Improve SPL directory and stat() cache using zend_srting* instead of char* 2021-02-26 02:28:46 +03:00
George Peter Banyard
3a4b89661e Remove quicktester
This is barely used and more of a hinderence than anything else

Closes GH-6712
2021-02-25 17:39:31 +00:00
Nikita Popov
362116c80b Merge branch 'PHP-8.0'
* PHP-8.0:
  crc32 module, clang spurious warning removal.
2021-02-25 10:19:06 +01:00
David CARLIER
ddea5c0816 crc32 module, clang spurious warning removal.
Closes GH-6725.
2021-02-25 10:17:21 +01:00
Dmitry Stogov
0f6c00200b Speed up __sleep() and __wakeup() calls 2021-02-25 12:16:22 +03:00
Dmitry Stogov
99d0f502dc Fixed error message 2021-02-24 19:12:32 +03:00
Christoph M. Becker
7f8ea83ef4 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #75776: Flushing streams with compression filter is broken
2021-02-22 15:33:57 +01:00
Christoph M. Becker
b418fe266d Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #75776: Flushing streams with compression filter is broken
2021-02-22 15:32:17 +01:00
Christoph M. Becker
963e50c8c4 Fix #75776: Flushing streams with compression filter is broken
First, the `bzip2.compress` filter has the same issue as `zlib.deflate`
so we port the respective fix[1] to ext/bz2.

Second, there is still an issue, if a stream with an attached
compression filter is flushed before it is closed, without any writes
in between.  In that case, the compression is never finalized.  We fix
this by enforcing a `_php_stream_flush()` with the `closing` flag set
in `_php_stream_free()`, whenever a write filter is attached.  This
call is superfluous for most write filters, but does not hurt, even
when it is unnecessary.

[1] <http://git.php.net/?p=php-src.git;a=commit;h=20e75329f2adb11dd231852c061926d0e4080929>

Closes GH-6703.
2021-02-22 15:28:46 +01:00
Máté Kocsis
4c6533c257
Generate class entries from stubs for com, standard, xmlreader, xmlwriter, xsl, zip, Zend
Closes GH-6706
2021-02-22 15:24:03 +01:00
Christoph M. Becker
d03be8bf86 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #80771: phpinfo(INFO_CREDITS) displays nothing in CLI
2021-02-22 14:34:45 +01:00
Christoph M. Becker
1d2bbce532 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #80771: phpinfo(INFO_CREDITS) displays nothing in CLI
2021-02-22 14:34:21 +01:00
Christoph M. Becker
073b6ea818 Fix #80771: phpinfo(INFO_CREDITS) displays nothing in CLI
There is no good reason not to show the credits in text based SAPIs,
except for brevity.  Thus, we suppress the credits from `php -i`.

Closes GH-6710.
2021-02-22 14:31:51 +01:00
Dmitry Stogov
3b29f5164d Revert "Remove class validation. zend_lookup_class_ex() performs it anyway."
This reverts commit 61cf1355fd.

Class name validation is only performed if key is not passed. Here, lc_name is passed as key.
2021-02-20 18:51:03 +03:00
Dmitry Stogov
61cf1355fd Remove class validation. zend_lookup_class_ex() performs it anyway. 2021-02-20 17:01:16 +03:00
Dmitry Stogov
bb1d61a848 Attempt to fix ext\standard\tests\file\basename_bug66395_variation2-win32.phpt and ext\standard\tests\file\pathinfo_basic1-win32.phpt 2021-02-19 21:48:19 +03:00
Dmitry Stogov
5e01542526 Improve basename(). Avoid calling mblen() for ASCII compatible locales. 2021-02-19 15:42:21 +03:00
Nikita Popov
e03284739f Initialize property to UNDEF on unserialize overwrite
The UNDEF marker here is important to prevent the creation of
a reference to the property currently being overwritten, which
would then leak.

This fixes oss-fuzz 6029559193534464, which was incorrectly
merged into oss-fuzz #30584 (which is reported at
https://github.com/google/oss-fuzz/issues/5211).
2021-02-18 11:10:20 +01:00
Nikita Popov
4fdaf84cc3 Merge branch 'PHP-8.0'
* PHP-8.0:
  Avoid signed integer overflow in substr()
2021-02-18 10:35:17 +01:00
Nikita Popov
85ffe8dcdc Avoid signed integer overflow in substr()
Perform negation after the (size_t) cast rather than before,
so as to avoid a signed integer overflow for PHP_INT_MIN.

Fixes oss-fuzz #31069.
2021-02-18 10:34:54 +01:00
Nikita Popov
b87080f3c2 Don't use unmangled name if property not found
This restores the previous behavior for this case. We'll continue
to use the mangled name, even if it does not correspond to a
declared property.

This also fixes an assertion failure for the case of property
overwrite, as the add_new was not guaranteed to be "new" previously.

Fixes oss-fuzz #31045.
2021-02-18 10:17:23 +01:00
Dmitry Stogov
76b3635607 unserialize() optimization. Omit class name validation before hash lookup, and perform it only before autoloading. 2021-02-17 13:30:52 +03:00
Dmitry Stogov
081349fe16 Improved unserialize() performance. Checks for object propery "visibility change" were moved, to be performed only if name/visibility had been really changed. 2021-02-16 15:27:58 +03:00
Nikita Popov
b10416a652 Deprecate passing null to non-nullable arg of internal function
This deprecates passing null to non-nullable scale arguments of
internal functions, with the eventual goal of making the behavior
consistent with userland functions, where null is never accepted
for non-nullable arguments.

This change is expected to cause quite a lot of fallout. In most
cases, calling code should be adjusted to avoid passing null. In
some cases, PHP should be adjusted to make some function arguments
nullable. I have already fixed a number of functions before landing
this, but feel free to file a bug if you encounter a function that
doesn't accept null, but probably should. (The rule of thumb for
this to be applicable is that the function must have special behavior
for 0 or "", which is distinct from the natural behavior of the
parameter.)

RFC: https://wiki.php.net/rfc/deprecate_null_to_scalar_internal_arg

Closes GH-6475.
2021-02-11 21:46:13 +01:00
Nikita Popov
f06895488a Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80718
2021-02-11 16:50:14 +01:00
Nikita Popov
5199686873 Fixed bug #80718 2021-02-11 16:49:39 +01:00
Nikita Popov
070e24d7a9 Allow all scalar types in ini_set()
This changes ini_set() to accept all scalar types
(string|int|float|bool|null) for the new value. The idea here is
that while the INI system ultimately works with strings, its value
interpretation is designed to be consistent with PHP's casting rules,
e.g. "1" and "" are interpreted as boolean true and false respectively.

I personally believe that writing ini_set('precision', 10) makes more
sense than ini_set('precision', '10'), and find strict_types to be
unnecessarily pedantic here.

Closes GH-6680.
2021-02-11 15:01:16 +01:00
Nikita Popov
bfbac70ec5 Merge branch 'PHP-8.0'
* PHP-8.0:
  Don't return null from password_get_info()
2021-02-11 10:23:09 +01:00
Nikita Popov
cec5e30889 Don't return null from password_get_info()
The get_info() handler should never fail, but even if it does,
we should still return a proper info array -- it doesn't make
sense that a completely incorrect hash returns an info array,
but a hash that is recognized but for which the options can't
be extracted would return null.
2021-02-11 10:21:31 +01:00
George Peter Banyard
3fbd3d2e2f Remove usage of float keys in arrays
Also make test output not produce trailling whitespaces

Closes GH-6662
2021-02-09 02:55:54 +00:00
Christoph M. Becker
050214b1f1 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #80706: mail(): Headers after Bcc headers may be ignored
2021-02-08 18:44:20 +01:00
Christoph M. Becker
f731477cd7 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #80706: mail(): Headers after Bcc headers may be ignored
2021-02-08 18:43:51 +01:00
Christoph M. Becker
ca7547c9e2 Fix #80706: mail(): Headers after Bcc headers may be ignored
We need to handle the case where a CRLF after a Bcc header is not the
beginning of a folding marker, because in that case the Bcc header was
not the last "thing".

Closes GH-6666.
2021-02-08 18:42:31 +01:00
Christoph M. Becker
eea4aac1a0 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #80654: file_get_contents() maxlen fails above (2**31)-1 bytes
2021-02-01 13:01:27 +01:00
Christoph M. Becker
766d5846b1 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #80654: file_get_contents() maxlen fails above (2**31)-1 bytes
2021-02-01 13:00:22 +01:00
Christoph M. Becker
7e9479083d Fix #80654: file_get_contents() maxlen fails above (2**31)-1 bytes
We remove the arbitrary restriction to `INT_MAX`; it is superfluous on
32bit systems where `ZEND_LONG_MAX == INT_MAX` anyway, and not useful
on 64bit systems, where larger files should be readable, if the
`memory_limit` is large enough.

Closes GH-6648.
2021-02-01 12:57:40 +01:00
Nikita Popov
800685e2f9 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix build
  crc32 mac build fix
2021-02-01 09:46:39 +01:00
David CARLIER
12d08db913 crc32 mac build fix
Closes GH-6651.
2021-02-01 09:43:12 +01:00
Stanislav Malyshev
23961ef382 Merge branch 'PHP-8.0'
* PHP-8.0:
  Rm unneeded function
2021-01-27 00:19:21 -08:00
Stanislav Malyshev
e9b8b085a7 Rm unneeded function 2021-01-27 00:18:49 -08:00
Stanislav Malyshev
21f861225a Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Rm unneeded function
2021-01-27 00:15:13 -08:00
Stanislav Malyshev
9c673083cd Rm unneeded function 2021-01-27 00:13:43 -08:00
Stanislav Malyshev
7eff4057de Merge branch 'PHP-8.0'
* PHP-8.0:
  Alternative fix for bug 77423
2021-01-26 23:01:40 -08:00
Stanislav Malyshev
effa287b35 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Alternative fix for bug 77423
2021-01-26 22:55:16 -08:00
Stanislav Malyshev
fbf8c758fe Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Alternative fix for bug 77423
2021-01-26 22:55:10 -08:00
Christoph M. Becker
4a89e726bd Alternative fix for bug 77423
That bug report originally was about `parse_url()` misbehaving, but the
security aspect was actually only regarding `FILTER_VALIDATE_URL`.
Since the changes to `parse_url_ex()` apparently affect userland code
which is relying on the sloppy URL parsing[1], this alternative
restores the old parsing behavior, but ensures that the userinfo is
checked for correctness for `FILTER_VALIDATE_URL`.

[1] <5174de7cd3 (commitcomment-45967652)>
2021-01-26 22:54:58 -08:00
Máté Kocsis
1954e59758
Add support for generating class entries from stubs
Closes GH-6289

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2021-01-26 11:50:36 +01:00
Dusk
13c430b1db Add array_is_list(array $array) function
This function tests if an array contains only sequential integer keys. While
list isn't an official type, this usage is consistent with the community usage
of "list" as an annotation type, cf.
https://psalm.dev/docs/annotating_code/type_syntax/array_types/#lists

Rebased and modified version of #4886

- Use .stub.php files
- Add opcache constant evaluation when argument is a constant
- Change from is_list(mixed $value) to array_is_list(array $array)

RFC: https://wiki.php.net/rfc/is_list

Co-Authored-By: Tyson Andre <tysonandre775@hotmail.com>
Co-Authored-By: Dusk <dusk@woofle.net>

Closes GH-6070
2021-01-20 18:53:48 -05:00
Nikita Popov
9be0ee4309 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #42560
2021-01-19 11:44:49 +01:00
Nikita Popov
1bdd8f7ae4 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fixed bug #42560
2021-01-19 11:44:22 +01:00
sj-i
5d31ee302d Fixed bug #42560
Check open_basedir after the fallback to the system's temporary
directory in tempnam().

In order to preserve the current behavior of upload_tmp_dir
(do not check explicitly specified dir, but check fallback),
new flags are added to check open_basedir for explicit dir
and for fallback.

Closes GH-6526.
2021-01-19 11:41:58 +01:00
Nikita Popov
f0d6151918 gen_stub: Don't use $aliasMap during verification
Some functions have multiple aliases, while the $aliasMap can
only record one.

Methodsynopsis generation probably shouldn't use it either, but
at least that case seems to only be interested in whether there
is an alias at all.
2021-01-18 16:04:14 +01:00
Craig Francis
50eca61f68 Use ENT_QUOTES|ENT_SUBSTITUTE default for HTML encoding and decoding functions
htmlspecialchars() etc now use ENT_QUOTES | ENT_SUBSTITUTE rather
than ENT_COMPAT by default.

Closes GH-6583.
2021-01-18 15:45:28 +01:00
David CARLIER
a3e55286a6 hrtime implementation update for Mac
Using a more modern and simpler api available since Sierra (2016).

Closes GH-6609.
2021-01-18 10:01:21 +01:00
Tyson Andre
81d20d003c Skip bug77423 if filter extension is unavailable. 2021-01-17 10:44:45 -05:00
Nikita Popov
141c4be70a Limit unserialization element count more aggressively
This is slightly more aggressive about rejecting obviously incorrect
element counts. Previously the number of elements was allowed to
match the number of characters. Now it is the number of characters
divided by two (this can actually be increased further to at least 4).

This doesn't really matter in the grand scheme of things (as it
just cuts maximum memory usage by half), but should fix
oss-fuzz #29356.
2021-01-15 17:07:51 +01:00
Nikita Popov
3e01f5afb1 Replace zend_bool uses with bool
We're starting to see a mix between uses of zend_bool and bool.
Replace all usages with the standard bool type everywhere.

Of course, zend_bool is retained as an alias.
2021-01-15 12:33:06 +01:00
Nikita Popov
e2c8ab7c33 Print "interned" instead of fake refcount in debug_zval_dump()
debug_zval_dump() currently prints refcount 1 for interned strings
and arrays, which does not really reflect the truth. These values
are not refcounted, so the refcount is misleading. Instead print
an "interned" tag.

Closes GH-6598.
2021-01-15 12:21:24 +01:00
Anna Filina
df30f09be5 Add test to verify file_get_contents error with folder
Closes GH-6600.
2021-01-14 23:49:26 +01:00
Nikita Popov
422d1665a2 Make convert_to_*_ex simple aliases of convert_to_*
Historically, the _ex variants separated the zval first, if a
conversion was necessary. This distinction no longer makes sense
since PHP 7.

The only difference that was still left is that _ex checked whether
the type is the same first, but the usage of these macros did not
actually distinguish on whether such an inlined check is valuable
or not in a given context.

Also drop the unused convert_to_explicit_type macros.
2021-01-14 12:11:11 +01:00
Nikita Popov
1b2aba285d Remove Z_PARAM separate params where they don't make sense
Separation can only possibly make sense for array parameters
(or something that can contain arrays, like zval parameters). It
never makes sense to separate a bool.

The deref parameters are also of dubious utility, but leaving them
for now.
2021-01-14 11:58:08 +01:00
sj-i
5a5f0adb2f Fix outdated comment about refcounting in array.c [ci skip]
Originally the reference count was incremented in here.
PHP7 removed the refcounting.
aa8ecbedcb (diff-9c1967d7282ea72ecea9d5dae0dab7349a34d48cc7a10ca38ff49a616f628e40L1954)

Closes GH-6603.
2021-01-14 09:52:40 +01:00
Nikita Popov
13e049ecfd Merge branch 'PHP-8.0'
* PHP-8.0:
  Use arc4random_buf on macOS
2021-01-12 10:43:18 +01:00
David CARLIER
7a049cd6a4 Use arc4random_buf on macOS
macOS uses an AES based arc4random_buf implementation since at least
macOS 10.2.

Closes GH-6591.
2021-01-12 10:42:09 +01:00
Nikita Popov
8b2b8563ef Remove some unnecessary zend_delete_global_variable uses 2021-01-08 11:31:31 +01:00