Commit graph

367 commits

Author SHA1 Message Date
Max Kellermann
308fd311ea ext/{standard,json,random,...}: add missing includes 2023-01-10 14:19:03 +00:00
Arnaud Le Blanc
246d13cd99 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  [ci skip] NEWS
  [ci skip] NEWS
  Return immediately when FD_SETSIZE is exceeded (#9602)
2022-10-01 11:24:23 +02:00
Arnaud Le Blanc
d4b99542d5 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  [ci skip] NEWS
  Return immediately when FD_SETSIZE is exceeded (#9602)
2022-10-01 11:23:34 +02:00
Arnaud Le Blanc
80232de0e4
Return immediately when FD_SETSIZE is exceeded (#9602) 2022-10-01 11:20:43 +02:00
Christoph M. Becker
33dae4bc02
Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix GH-9017: php_stream_sock_open_from_socket could return NULL
2022-07-19 17:08:05 +02:00
Christoph M. Becker
32d55f7422
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix GH-9017: php_stream_sock_open_from_socket could return NULL
2022-07-19 17:07:27 +02:00
Heiko Weber
3b7babf9b3
Fix GH-9017: php_stream_sock_open_from_socket could return NULL
Closes GH-9020.
2022-07-19 17:06:02 +02:00
George Peter Banyard
5171cb435a Fix [-Wundef] warnings in standard extension 2022-04-01 15:48:41 +01:00
Dmitry Stogov
90b7bde615 Use more compact representation for packed arrays.
- for packed arrays we store just an array of zvals without keys.
- the elements of packed array are accessible throuf as ht->arPacked[i]
  instead of ht->arData[i]
- in addition to general ZEND_HASH_FOREACH_* macros, we introduced similar
  familied for packed (ZEND_HASH_PACKED_FORECH_*) and real hashes
  (ZEND_HASH_MAP_FOREACH_*)
- introduced an additional family of macros to access elements of array
  (packed or real hashes) ZEND_ARRAY_ELEMET_SIZE, ZEND_ARRAY_ELEMET_EX,
  ZEND_ARRAY_ELEMET, ZEND_ARRAY_NEXT_ELEMENT, ZEND_ARRAY_PREV_ELEMENT
- zend_hash_minmax() prototype was changed to compare only values

Because of smaller data set, this patch may show performance improvement
on some apps and benchmarks that use packed arrays. (~1% on PHP-Parser)

TODO:
    - sapi/phpdbg needs special support for packed arrays (WATCH_ON_BUCKET).
    - zend_hash_sort_ex() may require converting packed arrays to hash.
2021-11-03 15:18:26 +03:00
Nikita Popov
54ef4f755a Merge branch 'PHP-8.1'
* PHP-8.1:
  Accept null and 0 for microseconds argument in stream_select()
2021-11-01 09:11:13 +01:00
Damjan Cvetko
a4ed17167c Accept null and 0 for microseconds argument in stream_select()
PHP 8.0 did not accept null for the usec argument, PHP 8.1 only
accepts null. This means you can't easily write code compatible
with both without triggering at least a deprecation warning.
Drop the deprecation warning for now.

Closes GH-7617.
2021-11-01 09:09:26 +01:00
George Peter Banyard
3240a74762 Use more specific return type for stream functions
Some void, some zend_result, some bool
2021-09-20 14:24:59 +01: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
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
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
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
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
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
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
9dda22bd1e Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fixed bug #80457
2020-12-02 11:29:41 +01:00
Nikita Popov
f2833ca1be Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fixed bug #80457
2020-12-02 11:29:06 +01:00
Nikita Popov
d6fcaf5da4 Fixed bug #80457
On x32 sizeof(size_t) != sizeof(zend_long), so we need to be
careful with sign extension here.

Patch by bruno dot premont at restena dot lu.
2020-12-02 11:26:10 +01:00
Nikita Popov
9ef2c5c303 stream_get_transports/wrappers cannot return false
These may return an empty array, but not false.
2020-09-22 12:02:39 +02:00
Máté Kocsis
c37a1cd650
Promote a few remaining errors in ext/standard
Closes GH-6110
2020-09-15 14:26:16 +02:00
Máté Kocsis
c98d47696f
Consolidate new union type ZPP macro names
They will now follow the canonical order of types. Older macros are
left intact due to maintaining BC.

Closes GH-6112
2020-09-11 11:00:18 +02:00
Máté Kocsis
2c96780e1c
Fix UNKNOWN default values in ext/standard
Closes GH-6026
2020-09-07 18:58:11 +02:00
Máté Kocsis
8107a1da5a
Use ZPP instead of custom type checks
We can add these types as a native type declaration to stubs as a side-effect. Closes GH-6068
2020-09-04 14:32:34 +02:00
George Peter Banyard
4a438b4469 Warning to Error promotion in ext/standard
Those should be the last ones other than set(raw)cookie()

Closes GH-5814
2020-09-03 17:43:57 +02:00
George Peter Banyard
fa8d9b1183 Improve type declarations for Zend APIs
Voidification of Zend API which always succeeded
Use bool argument types instead of int for boolean arguments
Use bool return type for functions which return true/false (1/0)
Use zend_result return type for functions which return SUCCESS/FAILURE as they don't follow normal boolean semantics

Closes GH-6002
2020-08-28 15:41:27 +02:00
Nikita Popov
e083cfaf6d Merge branch 'PHP-7.4'
* PHP-7.4:
  Require non-negative length in stream_get_contents()
2020-08-27 15:51:58 +02:00
Nikita Popov
8daf79215d Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Require non-negative length in stream_get_contents()
2020-08-27 15:51:35 +02:00
Nikita Popov
62dce97973 Require non-negative length in stream_get_contents()
If the length is not -1, require it to be non-negative.

Using such lengths doesn't make sense (as only -1 is special-case
to read in chunks, anything else will end up doing a huge upfront
allocation) and can lead to string allocation overflow.

A similar check is already in place for file_get_contents(). That
one does not allow -1 (and uses null instead), but this function
is explicitly specified to accept -1, so stick to that behavior.
2020-08-27 15:50:49 +02:00
Christoph M. Becker
ae7554270f Fix #79805: sapi_windows_vt100_support throws TypeError
It does not make sense to throw a `TypeError` when the stream can't be
analyzed.  If `sapi_windows_vt100_support()` is used as getter, we just
return `false` in that case; if the function is used as setter, we
additionally trigger a warning.

We also fix the test cases for this function, which have been broken
before.  Note that these tests are still whitespace sensitive.
2020-07-16 18:36:02 +02:00
Max Semenik
2b5de6f839
Remove proto comments from C files
Closes GH-5758
2020-07-06 21:13:34 +02:00
Nikita Popov
0280b83e11 Avoid some unnecessary uses of no_separation=0
For the rare cases where references are part of the API,
construct them explicitly. Otherwise do not allow separation.
2020-07-06 19:05:57 +02:00
Máté Kocsis
6111d64cda
Improve a last couple of argument error messages
Closes GH-5404
2020-04-20 13:09:00 +02:00
Nikita Popov
e9bdbce53f Merge branch 'PHP-7.4'
* PHP-7.4:
  Don't leak peername if accept fails
2020-04-14 16:08:43 +02:00
Nikita Popov
912e490196 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Don't leak peername if accept fails
2020-04-14 16:08:07 +02:00
Nikita Popov
b56fb9019e Don't leak peername if accept fails
Even if the accept fails, the peername may be populated.
2020-04-14 16:07:39 +02:00
Nikita Popov
b3f3a80f9c Make stream_socket_enable_crypto() session stream nullable 2020-04-09 16:10:33 +02:00
Nikita Popov
217dfc0832 Accept null context in stream_socket_(client|server) 2020-04-09 16:10:27 +02:00
Máté Kocsis
bb6f374048
Improve argument error messages in ext/standard
Closes GH-5198
2020-03-18 19:56:10 +01:00
Christoph M. Becker
f078bca729 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix #78210: Invalid pointer address
2020-03-11 11:32:46 +01:00
Christoph M. Becker
8657f03084 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #78210: Invalid pointer address
2020-03-11 11:31:26 +01:00
Christoph M. Becker
53797c206a Fix #78210: Invalid pointer address
This is actually about three distinct issues:

* If an empty string is passed as $address to `stream_socket_sendto()`,
  the `sa` is not initialized, so we must not pass it as `addr` to
  `php_stream_xport_sendto()`.

* On POSIX, `recvfrom()` truncates messages which are too long to fit
  into the specified buffer (unless `MSG_PEEK` is given), discards the
  excessive bytes, and returns the buffer length.  On Windows, the same
  happens, but `recvfrom()` returns `SOCKET_ERROR` with the error code
  `WSAEMSGSIZE`.  We have to catch this for best POSIX compatibility.

* In `php_network_parse_network_address_with_port()`, we have to zero
  `in6` (not only its alias `sa`) to properly support IPv6.

Co-Authored-By: Nikita Popov <nikita.ppv@googlemail.com>
2020-03-11 11:30:15 +01:00
Máté Kocsis
d1764ca330
Make error messages more consistent by fixing capitalization
Closes GH-5066 As a first step, let's capitalize their initial letter when it is applicable.
2020-01-17 14:52:46 +01:00