Commit Graph

5962 Commits

Author SHA1 Message Date
Patrick Allaert
628670c391
Prepare for 8.1.2 2021-12-02 14:20:36 +01:00
Sara Golemon
999c6f2c5d
Bump for 8.0.15 2021-12-02 05:09:07 +00:00
Christoph M. Becker
e73cccd9f2
Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix #81659: stream_get_contents() may unnecessarily overallocate
2021-11-29 14:50:54 +01:00
Christoph M. Becker
b0823438a9
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix #81659: stream_get_contents() may unnecessarily overallocate
2021-11-29 14:50:19 +01:00
Christoph M. Becker
f3bd24a200
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #81659: stream_get_contents() may unnecessarily overallocate
2021-11-29 14:48:11 +01:00
Christoph M. Becker
31749aac62
Fix #81659: stream_get_contents() may unnecessarily overallocate
Since we're going to read from the current stream position anyway, the
`max_len` should be the size of the file minus the current position
(still catering to potentially filtered streams).  We must, however,
make sure to cater to the file position being beyond the actual file
size.

While we're at, we also fix the step size in the comment, which is 8K.

A further optimization could be done for unfiltered streams, thus
saving that step size, but 8K might not be worth it.

Closes GH-7693.
2021-11-29 14:46:09 +01:00
Patrick Allaert
ac96db6767
Preparing for 8.1.1 2021-11-27 11:06:14 +01:00
Dmitry Stogov
067df26344 Use memrchr() when available
On x86_64 glibc memrchr() uses SSE/AVX CPU extensions and works much
faster then naive loop. On x86 32-bit we still use inlined version.

memrchr() is a GNU extension. Its prototype  becomes available when
<string.h> is included with defined _GNU_SOURCE macro. Previously, we
defined it in "php_config.h", but some sources may include <string.h>
befire it. To avod mess we also pass -D_GNU_SOURCE to C compiler.
2021-11-24 16:13:34 +03:00
Nikita Popov
7cbf4bde3e Merge branch 'PHP-8.1'
* PHP-8.1:
  Add FPM test for php_admin_value doc_root usage
  Fix for bug in file handling refactor.
2021-11-23 18:36:45 +01:00
jlbprof
96da46199f Fix for bug in file handling refactor.
While testing the cPanel usage of PHP-FPM, we stumbled on this bug.
Without the fix, the zend_string is corrupted and getting odd filenames

When using FPM we kept getting "No input file specified".

I work for cPanel and we use PHP extensively.
2021-11-23 18:34:48 +01:00
Ben Ramsey
89f28fafca
The PHP-8.1 branch is now for 8.1.0 2021-11-09 17:49:14 -06:00
Nikita Popov
aefe802e05 Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix bug #81591: ignore_repeated_errors broken
2021-11-04 16:25:24 +01:00
Nikita Popov
6ebabaa50c Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix bug #81591: ignore_repeated_errors broken
2021-11-04 16:25:18 +01:00
Nikita Popov
4c171ed5eb Fix bug #81591: ignore_repeated_errors broken
We should suppress the error if the message is the same, not if
it's different. Apparently we had no test coverage for these
options.
2021-11-04 16:23:55 +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
Derick Rethans
05b212bb3d Prepare for 7.4.27 2021-11-02 16:39:44 +00:00
Sara Golemon
2d4bfcfd3b
Prep for 8.0.14 2021-11-02 15:55:12 +00:00
Patrick Allaert
5dc2c38faf
Configuring for 8.1.0RC6 2021-10-27 02:15:21 +02:00
Christoph M. Becker
e22b305ffb
Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix #81518: Header injection via default_mimetype / default_charset
2021-10-14 12:24:05 +02:00
Christoph M. Becker
f99c69fc2e
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix #81518: Header injection via default_mimetype / default_charset
2021-10-14 12:23:43 +02:00
Christoph M. Becker
b7f3b67060
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #81518: Header injection via default_mimetype / default_charset
2021-10-14 12:21:35 +02:00
Christoph M. Becker
365769366b
Fix #81518: Header injection via default_mimetype / default_charset
We forbid setting these INI options to values containing NUL bytes, CR
or LF.

Closes GH-7574.
2021-10-14 12:16:19 +02:00
Ben Ramsey
daf6a46177
The PHP-8.1 branch is now for 8.1.0RC5 2021-10-12 18:50:51 -05:00
Derick Rethans
9733d49e14 Remove now superfluous tests due to changes in tzdata 2021-10-08 13:51:21 +01:00
Kamil Tekiela
c3dda473cc
Fix 'can not' in test data and in code comments 2021-10-05 09:51:58 +01:00
Christoph M. Becker
4a8ca7294e
Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix #81475: stream_isatty emits warning with attached stream wrapper
2021-09-29 13:49:40 +02:00
Christoph M. Becker
41e0081901
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix #81475: stream_isatty emits warning with attached stream wrapper
2021-09-29 13:49:15 +02:00
Christoph M. Becker
e2d9ca7b19
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #81475: stream_isatty emits warning with attached stream wrapper
2021-09-29 13:47:13 +02:00
Christoph M. Becker
23e13e2c8f
Fix #81475: stream_isatty emits warning with attached stream wrapper
We must not issue warnings, if `show_err` is false.

Closes GH-7513.
2021-09-29 13:44:09 +02:00
Ben Ramsey
68ee1b40fc
The PHP-8.1 branch is now for 8.1.0RC4 2021-09-28 16:34:46 -05:00
Nikita Popov
b976ad09ab Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix leak of invalid stream_read() return value
2021-09-28 15:58:13 +02:00
Nikita Popov
f79bd08573 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix leak of invalid stream_read() return value
2021-09-28 15:58:05 +02:00
Nikita Popov
2f798d99b7 Fix leak of invalid stream_read() return value
Fixes oss-fuzz 6225190686687232 (part of #38542).
2021-09-28 15:57:55 +02:00
Nikita Popov
605ac4649c Merge branch 'PHP-8.1'
* PHP-8.1:
  Use ASCII lower case for misc case folding
2021-09-24 09:23:18 +02:00
Tim Starling
c96be7b8f2 Use ASCII lower case for misc case folding
Use ASCII case conversion instead of locale-dependent case conversion in
the following places:

* grapheme_stripos() and grapheme_strripos() in the "fast" path
* ldap_get_entries()
* oci_pconnect() for case folding of parameters when constructing a key
  into the connection or session pool
* SoapClient: case folding of function names
* get_meta_tags(): case conversion of property names
* http stream wrapper: header names
* phpinfo(): anchor names
* php_verror(): docref URLs
* rfc1867.c: Content-Type boundary parameter name
* streams.c: stream protocol names

Using locale-dependent case folding for these cases is either
unnecessary or actively incorrect. These functions could have
misbehaved when used with certain locales (e.g. Turkish).

Closes GH-7511.
2021-09-24 09:20:08 +02: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
e2d05bfcb2 Allow get_request_time() hook to fail
In particular, this allows using the hook without server_context.
The apache2handler implementation now checks that server_context
is available itself, as that's the implementation that cares
about it.
2021-09-16 16:54:07 +02:00
Nikita Popov
0652e81041 Merge branch 'PHP-8.1'
* PHP-8.1:
  Don't leak header callback if headers already sent
2021-09-16 15:31:39 +02:00
Nikita Popov
9bff96396d Don't leak header callback if headers already sent
We need to avoid storing it in the first place, as we don't
really have a good place to release it later. If headers haven't
been sent yet, send_headers will do this. sapi_deactive happens
too late in the shutdown sequence and will result in leak reports.
2021-09-16 15:31:27 +02:00
Patrick Allaert
cba708bbb6
Configuring for 8.1.0RC3 2021-09-14 18:17:42 +02:00
Sara Golemon
5e1e4a8963
Prep for 8.0.12 2021-09-07 15:16:11 +00:00
Máté Kocsis
a1a8e9032c
Remove unnecessary PHP_FUNCTION() declarations (#7472) 2021-09-07 10:04:00 +02:00
Patrick Allaert
d6d6491153
Preparing for 8.1.0RC2 2021-09-01 18:22:32 +02:00
Nikita Popov
485d3acfe6 Make zend_call_function() failure handling consistent
This API had rather peculiar behavior in case the provided function
is not callable. For some types of failures, it would silently
return FAILURE (e.g. a function does not exist), while for others
(e.g. a class does not exist) it would generate a warning. Depending
on what the calling code does, this can either result in silent
failure or duplicate errors.

This commit switches the contract such that zend_call_function()
always (*) succeeds, though that success might be in the form of
throwing an exception. Calling a non-callable will now consistently
throw an exception.

There are some rare callers that do want to ignore missing methods,
for legacy APIs that are specific with optional methods. For these
use cases a new zend_call_method_if_exists() API is provided.

Calling code generally does not need to explicitly check for and
report zend_call_function() failures -- it can rely on
zend_call_function() having already done so. However, existing
code that does check for failure should continue to work fine.

(*) The only exception to this is if EG(active) being false during
late engine shutdown. This is not relevant to most code, but code
running in destructors and similar may need to be aware of the
possibility.
2021-09-01 16:09:23 +02:00
Nikita Popov
3ec14000c6 Remove UNDEF checks in userstream implementation
I don't see how object can be UNDEF here -- and just passing
NULL in that case is not going to do anything reasonable either.
It would fall back to global functions with the same name.
2021-09-01 12:31:22 +02:00
Nikita Popov
27901e0f6a Restore dev version 2021-09-01 09:56:54 +02:00
Patrick Allaert
1c33ddb5e5
Prepare for PHP 8.2 2021-08-31 19:13:49 +02:00
Patrick Allaert
5764414eb8
Prepare for PHP 8.1.0RC1 2021-08-31 18:57:44 +02:00
MARiA so cute
aec08cc841
Improve the success rate when use mkdir() in multiprocessing environment (#7383)
Improve the success rate when use mkdir() in multiprocessing environment
2021-08-18 12:34:04 +02:00
Nikita Popov
9574627552 Clean up recursive mkdir logic
Rewrite this as a loop with a single VCWD_MKDIR call and a
subsequent advance to the next directory.
2021-08-17 14:20:44 +02:00
Nikita Popov
3c7ff25fbe Reduce nesting in mkdir implementation 2021-08-17 12:25:38 +02:00
Christoph M. Becker
e9b28528d6
Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #81346: Non-seekable streams don't update position after write
2021-08-10 16:51:56 +02:00
Christoph M. Becker
a2b92d6baa
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #81346: Non-seekable streams don't update position after write
2021-08-10 16:50:36 +02:00
Christoph M. Becker
4a1af1f871
Fix #81346: Non-seekable streams don't update position after write
The stream position is not related to the buffer, and needs to be
updated for non-seekable streams as well.  The erroneous condition
around the position update is a relict of an old commit[1].

The unexpected test expectation is due to bug #81345.

[1] <088e2692c3>

Closes GH-7356.
2021-08-10 16:49:07 +02:00
Christoph M. Becker
4ff82eb96a
Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #81302: Stream position after stream filter removed
2021-08-10 16:42:03 +02:00
Christoph M. Becker
2e71c94c9b
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #81302: Stream position after stream filter removed
2021-08-10 16:41:14 +02:00
Christoph M. Becker
40b31fcc80
Fix #81302: Stream position after stream filter removed
When flushing the stream filters actually causes data to be written to
the stream, we need to update its position, because that is not done by
the streams' write methods.

Closes GH-7354.
2021-08-10 16:39:55 +02:00
Nikita Popov
e14fbc84ac Remove FORMAT_CONV_MAX_PRECISION
This used to be necessary in the past because the NUM_BUF_SIZE
was set to 512, which is shorter than DOUBLE_MAX_LENGTH. Now the
value is either DOUBLE_MAX_LENGTH or larger (2048).
2021-08-02 15:59:26 +02:00
Nikita Popov
d28f6e694d Move php_gcvt to zend_gcvt
Also move PHP_DOUBLE_MAX_LENGTH to ZEND_DOUBLE_MAX_LENGTH.
2021-08-02 14:51:46 +02:00
Christoph M. Becker
ccb6642c91
Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #81294: Segfault when removing a filter
2021-07-27 12:17:07 +02:00
Christoph M. Becker
bf9afc184f
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #81294: Segfault when removing a filter
2021-07-27 12:14:22 +02:00
Christoph M. Becker
1fa26eccba
Fix #81294: Segfault when removing a filter
We need to call the proper method.

Closes GH-7308.
2021-07-27 12:12:02 +02:00
Nikita Popov
21d9931007 Fix user ini parsing under RC_DEBUG
Suppress checking during the actual parsing, but make sure to
duplicate strings on activate. The parsing result may be shared
across requests, but activation should work on per-request strings.
2021-07-21 09:14:31 +02:00
Nikita Popov
1da5df8029 Don't enable rc_debug mode if module startup fails 2021-07-21 09:14:15 +02:00
Nikita Popov
a4db74364d Remove THREAD_LS
This sounds like it will give you a thread local storage, but in
truth ... it does absolutely nothing.
2021-07-19 16:15:31 +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
29e5e4719c
Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #72595: php_output_handler_append illegal write access
2021-07-15 15:31:39 +02:00
Christoph M. Becker
c6b7f6c39f
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #72595: php_output_handler_append illegal write access
2021-07-15 15:29:48 +02:00
Christoph M. Becker
a942cf5b02
Fix #72595: php_output_handler_append illegal write access
We must make sure that `handler->buffer.size + grow_max` does not
overflow, so we're using `safe_erealloc()` instead.

Closes GH-7241.
2021-07-15 15:26:42 +02:00
George Peter Banyard
282abfed95 Drop register keyword 2021-07-15 10:40:36 +02:00
George Peter Banyard
02e48d99c9 Use standard 64bit signed int type 2021-07-15 10:40:36 +02:00
George Peter Banyard
97785545cf Use standard 64bit unsigned int type 2021-07-15 10:40:36 +02:00
George Peter Banyard
b901c0528c Refactor conversion function
Use a size_t instead of int because it tracks the size of the string
Cast to int to maintain the C stdlib API
2021-07-15 10:40:36 +02:00
George Peter Banyard
2bf68b3c01 Remove unused macro 2021-07-15 10:40:36 +02:00
George Peter Banyard
5e4d727f6a Use standard bool type instead of boolean_e 2021-07-15 10:40:36 +02:00
George Peter Banyard
10f416f5c2 Use standard bool type instead of bool_int 2021-07-15 10:40:36 +02:00
Sara Golemon
7dc35ac8a7
Bump to 8.0.10 2021-07-13 14:10:35 +00:00
Nikita Popov
efbb2198d4 Return value from ZEND_ATOL
Instead of assigning it as part of the macro itself, which makes
usage quite awkward.
2021-07-12 16:51:24 +02:00
twosee
6086e174be
Remove unnecessary sockaddr memory allocation (#7219)
The size of sockaddr_in and sockaddr_in6 is known on compile-time and it is not that big for the stack.
Also optimized the code.
2021-07-09 10:38:19 +08: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
2c59a6b241 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix bug #80728: Don't reset the timeout on ini deactivate
2021-06-29 16:37:43 +02:00
Nikita Popov
65bd8d281f Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix bug #80728: Don't reset the timeout on ini deactivate
2021-06-29 16:37:27 +02:00
Calvin Buckley
98a21d1dfb Fix bug #80728: Don't reset the timeout on ini deactivate
When the time limit for a script is changed, when the script ends,
its INI value will be reset. This calls the event handler for the
timeout change, which will unset then reset the timeout. However,
this is done even if the script is done executing, and say, the CGI
or CLI web server process is idle.

This is probably incorrect, but isn't a problem on most platforms,
because PHP uses a timer that only ticks when the process is active
(that is, executing code). Since when it's idle, it's blocking on
listen/read, it won't tick because nothing executes. However, on
platforms where only the real-time timer is supported, (Cygwin/PASE)
it ticks regardless of if PHP is even executing. This means that the
idle processes are subject to timeouts from the INI reset on script
end.

This makes it so the timer is never set if the state is deactivating.
Testing with the CLI web server indicates the timer no longer
spuriously activates under PASE.

Closes GH-6683.
2021-06-29 16:36:46 +02:00
Patrick Allaert
aff365871a Fixed some spaces used instead of tabs 2021-06-29 11:30:26 +02:00
Benjamin Eberlei
0ca5ab4fa5
Add host for php_network_getaddresses getaddrinfo failed error message. (#7181) 2021-06-22 17:18:09 +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
0d6358f2cf Drop support for printf p modifier
To be conservative, cause a fatal error if the p modifier is
encountered, in case this is still used by some extension.
2021-06-16 17:59:00 +02:00
Gabriel Caruso
b81c3b5b1c
Prepare for PHP 8.0.9 2021-06-15 09:19:13 +02:00
Nikita Popov
dd91170ee2 Avoid make_printable_zval() in other printf implementations as well
This is the same as the previous commit, for copies of that code.
2021-06-10 10:19:05 +02:00
Nikita Popov
a1473aadf8 Avoid make_printable_zval in snprintf
Use zval_get_tmp_string() instead.
2021-06-10 10:12:57 +02:00
David CARLIER
e69729f2ba
fdatasync disable warning on macOS. (#7122)
The symbol exists and picked up but nowhere to be found on the headers.
tested on gcc/clang from homebrew and clang/Xcode.
2021-06-09 03:51:10 +02:00
Nikita Popov
291d8db7c5 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #81104
2021-06-08 14:34:08 +02:00
Nikita Popov
d29f15ce5f Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fixed bug #81104
2021-06-08 14:33:29 +02:00
Nikita Popov
d8165c2502 Fixed bug #81104
When the memory limit is restored during shutdown, we may still
be using a lot of memory. Ignore the failure at that point and
set it again after the MM is shut down, at which point memory
usage should be at its lowest point.
2021-06-08 14:31:55 +02:00
Nikita Popov
e9b005158f Fix output buffer discard on memory limit
Move this code directly into the error handler, and check the
heap->overflow flag. Discarding output here allows us to print
the normal memory limit message to standard output. Otherwise
nothing would be printed unless a different log medium was used,
which makes for a suboptimal debugging experience.
2021-05-31 16:30:36 +02:00
Nikita Popov
1aafed5e98 Remove zend_set_memory_limit_ex() API
This was added temporarily for the PHP-8.0 branch to avoid an
ABI break.
2021-05-31 15:27:46 +02:00
Nikita Popov
b4559e7ae4 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #81070
2021-05-31 15:24:29 +02:00
Nikita Popov
324ad2f42c Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fixed bug #81070

This is a non-trivial merge. To avoid an ABI break, a new
zend_set_memory_limit_ex() function is added.
2021-05-31 15:24:00 +02:00
Peter van Dommelen
1b3b5c94e5 Fixed bug #81070
When the memory limit is reduced using an `ini_set("memory_limit", ..)`
below the currently allocated memory, the out-of-memory check overflowed.
Instead of implementing additional checks during allocation,
`zend_set_memory_limit()` now validates the new memory limit. When
below the current memory usage the ini_set call will fail and throw
a warning.

This is part of GH-7040.
2021-05-31 15:18:58 +02:00
Nikita Popov
7db146eea7
Remove "inline" defines on Windows (#7071)
Newer MSVC versions support the `inline` keyword, so we do not need to explicitly define it. We also shouldn't define `inline` to `__forceinline`, as we already have `zend_always_inline` to indicate this requirement.
2021-05-31 10:05:18 +02:00
Christoph M. Becker
fda53548b5
Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #76359: open_basedir bypass through adding ".."
2021-05-25 13:47:25 +02:00
Christoph M. Becker
a5601b2ab5
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #76359: open_basedir bypass through adding ".."
2021-05-25 13:46:38 +02:00
Christoph M. Becker
ee9e07541f
Fix #76359: open_basedir bypass through adding ".."
We explicitly forbid adding paths with a leading `..` to `open_basedir`
at runtime.

Closes GH-7024.
2021-05-25 13:44:53 +02:00
Christoph M. Becker
59522ba968
Update version in php_version.h as well
The version there is automatically updated during `./configure`, but
not on Windows.
2021-05-22 15:42:57 +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
Sara Golemon
64918fee97
Prep for 8.0.8 2021-05-19 19:18:56 +00: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
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
Björn Tantau
d764f1dc12
Fix #77372: Retain full path of files for directory uploads (#6917)
To fix https://bugs.php.net/bug.php?id=77372 and improve support of `<input type="file" name="files" multiple webkitdirectory>` I introduced another item to the `$_FILES` array called `full_path`, containing the full filename, as supplied by the user-agent.

Co-authored-by: Björn Tantau <bjoern@bjoern-tantau.de>
2021-05-14 11:43:55 +02: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
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
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
Michael Voříšek
cc2c810dcf
Remove no longer used "log_errors_max_len" ini directive (#6838) 2021-05-07 19:07:35 -05:00
Remi Collet
e5b6f43ec7
get rid of inet_addr usage 2021-05-06 16:32:06 +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
Christoph M. Becker
125fc0b8d4
Update version in php_version.h as well
The version there is automatically updated during `./configure`, but
not on Windows.
2021-05-05 15:18:46 +02:00
Sara Golemon
f020d537b0
Reset for 8.0.7 2021-05-04 17:17:20 +00:00
Nikita Popov
61ba79df17 Remove variable registration code from rfc1867
This now longer does anything -- registering a variable for a NULL
array is a no-op.
2021-04-27 12:30:46 +02:00
Christoph M. Becker
3bb62eee5b
Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #67792: HTTP Authorization schemes are treated as case-sensitive
2021-04-23 15:58:21 +02:00
Christoph M. Becker
23a192d12d
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #67792: HTTP Authorization schemes are treated as case-sensitive
2021-04-23 15:57:11 +02:00
Christoph M. Becker
39ddf6b89c
Fix #67792: HTTP Authorization schemes are treated as case-sensitive
We use `zend_binary_strncasecmp()` to avoid any locale issues, and
refactor.  We also add a test case for Digest authentication.

Closes GH-6900.
2021-04-23 15:54:17 +02:00
Nikita Popov
b66eb866c9 Convert last_error_file to zend_string 2021-04-23 11:05:14 +02:00
Nikita Popov
a1c6ee2164 Convert error filename to zend_string
Error handling functions/callbacks now accept the error filename
as a zend_string* instead of a const char*.
2021-04-23 11:05:14 +02:00
David CARLIER
7aba6de1d0
stream: Fix MacOS build. fsync as alias for fdatasync. (#6882)
If fdatasync is not available, use fsync instead.

For some reason, fdatasync is available when using clang from Xcode, even though no declaration is present in headers.
2021-04-21 16:21:43 +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
George Peter Banyard
cef0076a88 Signal that the stream option passed is an error
Otherwise this falls through to the next case statement.
2021-04-19 13:59:18 +01:00
Christoph M. Becker
0071c7ed7e
Update php_version.h 2021-04-16 17:42:29 +02: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
Gabriel Caruso
79872ac9c2
8.0.6 is the next version 2021-04-13 12:41:21 +02:00
Josh Soref
462da6e09c Fix spelling and grammar mistakes
This PR corrects misspellings identified by the check-spelling action.

The misspellings have been reported at jsoref@b6ba3e2#commitcomment-48946465

The action reports that the changes in this PR would make it happy: jsoref@602417c

Closes GH-6822.
2021-04-13 12:09:37 +02:00
Nikita Popov
765cb40bf5 Go back to not reporting startup leaks
Unfortunately CG(unclean_shutdown) may not be initialized at this
point in ZTS builds.
2021-04-11 11:01:04 +02:00
Nikita Popov
cbf3240d91 Don't report leak on unclean_shutdown during startup
In particular if an invalid ini option is specified.
2021-04-09 21:16:02 +02:00
Nikita Popov
718dd06744 Don't suppress startup leaks 2021-04-09 16:32:58 +02:00
Nikita Popov
f0d783b7bf Free expanded filename in php_init_config()
This leak ends up getting suppressed, but is rather annoying when
not using ZEND_TRACKED_ALLOC.
2021-04-09 16:29:03 +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
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
Nikita Popov
ad4b928750 Drop unused fgetss_state member 2021-04-08 22:27:00 +02:00
Christoph M. Becker
0a181ca27a
Update version in main/php_version.h as well
Otherwise the file is modified by each new build, what is confusing.
2021-04-07 12:45:21 +02:00
George Peter Banyard
5caaf40b43
Introduce pseudo-keyword ZEND_FALLTHROUGH
And use it instead of comments
2021-04-07 00:46:29 +01: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
Nikita Popov
48986653fe Remove unused READDIR_R lock 2021-03-22 10:48:59 +01:00
George Peter Banyard
ddfe269aa8 Use zend_string_equals() API instead of strcmp() in main.c 2021-03-17 16:36:16 +00:00
Dmitry Stogov
356ef5bd0e Fix CLANG/RELEASE build (this is a workaround for probable bug in CLANG) 2021-03-17 15:50:36 +03:00
Christoph M. Becker
c7fadd2328 8.0.5 is next
We also move the NEWS entry for bug 80847 to the proper version.
2021-03-17 12:14:26 +01: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
George Peter Banyard
d4530f807a Use zend_string* & more legible API for php_get_display_errors_mode() 2021-03-14 15:06:15 +00:00
Calison
021c988a6f Return early on php display error for better legibility
Closes GH-6760

Signed-off-by: George Peter Banyard <girgias@php.net>
2021-03-14 14:25:26 +00:00
Dmitry Stogov
13e4ce386b Improve SPL directory and stat() cache using zend_srting* instead of char* 2021-02-26 02:28:46 +03:00
Christoph M. Becker
81396ea890 Update php_version.h to proper version number 2021-02-23 12:09:06 +01: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
Sara Golemon
8c6db654e7
Prep for 8.0.4 2021-02-17 15:24:43 +00:00
Dmitry Stogov
4b79dba932 Added Inheritance Cache.
This is a new transparent technology that eliminates overhead of PHP class inheritance.

PHP  classes are compiled and cached (by opcahce) separately, however their "linking" was done at run-time - on each request. The process of "linking" may involve a number of compatibility checks and borrowing methods/properties/constants form parent and traits. This takes significant time, but the result is the same on each request.

Inheritance Cache performs "linking" for unique set of all the depending classes (parent, interfaces, traits, property types, method types involved into compatibility checks) once and stores result in opcache shared memory. As a part of the this patch, I removed limitations for immutable classes (unresolved constants, typed properties and covariant type checks). So now all classes stored in opcache are "immutable". They may be lazily loaded into process memory, if necessary, but this usually occurs just once (on first linking).

The patch shows 8% improvement on Symphony "Hello World" app.
2021-02-09 22:53:57 +03:00
Christoph M. Becker
94af11d5e1 Update version
That appears to have been forgotten for a while.
2021-01-26 19:08:23 +01:00
Gabriel Caruso
34f0f60db5
Next is 8.0.3 2021-01-19 13:00:48 -03: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
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
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
Christoph M. Becker
89d4b6b790 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #80384: limit read buffer size
2020-12-23 13:53:19 +01:00
Christoph M. Becker
7d9ddd61ec Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #80384: limit read buffer size
2020-12-23 13:52:45 +01:00
Adam Seitz
70dfbe0068 Fix #80384: limit read buffer size
In the case of a stream with no filters, php_stream_fill_read_buffer
only reads stream->chunk_size into the read buffer. If the stream has
filters attached, it could unnecessarily buffer a large amount of data.

With this change, php_stream_fill_read_buffer only proceeds until either
the requested size or stream->chunk_size is available in the read buffer.

Co-authored-by: Christoph M. Becker <cmbecker69@gmx.de>

Closes GH-6444.
2020-12-23 13:49:56 +01:00
Nikita Popov
7904a087ec Back memory stream by a zend_string
This allows reusing an existing zend_string inside a memory stream
without reallocating. For non-readonly streams, the string will
only get separated on write.
2020-12-18 17:07:07 +01:00
Nikita Popov
9ec6392d80 Remove unused smax member from memory stream 2020-12-18 16:40:23 +01:00
Gabriel Caruso
f1f78ac875
Next is 8.0.2 2020-12-15 10:30:55 -03:00
Christoph M. Becker
615197ae3d Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #77069: stream filter loses final block of data
2020-12-08 11:49:41 +01:00
Christoph M. Becker
d6ae0f010e Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #77069: stream filter loses final block of data
2020-12-08 11:49:28 +01:00
Christoph M. Becker
65f5573bc8 Fix #77069: stream filter loses final block of data
Reading from a stream may return greater than zero, but nonetheless the
stream's EOF flag may have been set.  We have to cater to this
condition by setting the close flag for filters.

We also have to cater to that change in the zlib.inflate filter:

If `inflate()` is called with flush mode `Z_FINISH`, but the output
buffer is not large enough to inflate all available data, it fails with
`Z_BUF_ERROR`.  However, `Z_BUF_ERROR` is not fatal; in fact, the zlib
manual states: "If deflate returns with Z_OK or Z_BUF_ERROR, this
function must be called again with Z_FINISH and more output space
(updated avail_out) but no more input data, until it returns with
Z_STREAM_END or an error."  Hence, we do so.

Closes GH-6001.
2020-12-08 11:47:49 +01:00
Nikita Popov
39c59e084c Merge branch 'PHP-8.0'
* PHP-8.0:
  Suppress stream errors in mysqlnd
2020-11-30 15:06:40 +01:00
Nikita Popov
24a19cc232 Suppress stream errors in mysqlnd
mysqlnd currently sets error_reporting=0 to suppress errors while
writing to streams. Unfortunately these errors are still visible
to userland error handlers, which is a source of confusion.
See for example https://bugs.php.net/bug.php?id=80412.

Instead add a stream flag that suppresses the emission of
read/write errors in the first place, and set it in mysqlnd.

I think it might be useful to have this option for userland as
well in the future, but for now this is just an internal
mechanism.

Closes GH-6458.
2020-11-30 15:06:28 +01:00
Sara Golemon
3c44e9c080 8.0 branch should be prepping for 8.0.1 2020-11-19 14:37:44 +00:00
Sammy Kaye Powers
e974becbb1
Merge branch 'PHP-8.0'
* PHP-8.0:
  Fire open observer end handlers after a zend_bailout
2020-11-16 15:13:29 -08:00
Sammy Kaye Powers
0425a6697a
Fire open observer end handlers after a zend_bailout
Closes GH-6377
2020-11-16 15:12:57 -08:00
Christoph M. Becker
1e0610fe24 Merge branch 'PHP-8.0'
* PHP-8.0:
  Strip trailing line breaks and periods from Windows error messages
2020-11-12 16:43:57 +01:00
Christoph M. Becker
a08a2b48b4 Strip trailing line breaks and periods from Windows error messages
PHP error messages should not contain line breaks, so we remove these
from the Windows specific error messages.  We also remove trailing
periods for the same reason.

Closes GH-6423.
2020-11-12 16:42:28 +01:00
Derick Rethans
25643b56a2 Update version in 7.4 branch 2020-11-07 18:48:13 +00:00
Nikita Popov
a5597c3e8d Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix invalid memory read on libpath
2020-10-21 10:07:24 +02:00
twosee
5998b2a3a6 Fix invalid memory read on libpath
Introduced in 3e33e1e86d.

Closes GH-6362.
2020-10-21 10:07:07 +02:00
Christoph M. Becker
521c36c855 Remove IGNORE_URL_WIN macro
This macro is defined to zero as of PHP 5.0.0, and as the comment
indicates, is no longer relevant.  Thus, we remove the definition and
all usages from the core and bundled extensions.

Closes GH-6351.
2020-10-18 23:36:36 +02:00
Nikita Popov
9a669fa3d6 Merge branch 'PHP-8.0'
* PHP-8.0:
  Properly handle NULL output start filename
2020-10-16 18:38:34 +02:00
Nikita Popov
d6a18a7738 Properly handle NULL output start filename 2020-10-16 18:38:03 +02:00
Nikita Popov
d694e43c86 Remove unused global 2020-10-16 17:32:02 +02:00
Nikita Popov
808029c049 Merge branch 'PHP-8.0'
* PHP-8.0:
  Make sure output start filename is not freed early
2020-10-16 17:29:22 +02:00
Nikita Popov
97202d9d84 Make sure output start filename is not freed early
As filenames are no longer interned, we need to keep a reference
to the zend_string to make sure it isn't freed.

To avoid a nominal source compatibility break, create a new member
in the globals.
2020-10-16 17:27:52 +02:00
George Peter Banyard
150ebfdf77 Suppress bogus [-Wlogical-op] warning from GCC
See GCC bug 69602: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69602
which emits the warning for (errno == EWOULDBLOCK || errno == EAGAIN)
which is the correct way of handling errors as the value of EWOULDBLOCK
and EAGAIN is implementation defined.

Therefore introduce a new macro function PHP_IS_TRANSIENT_ERROR()
which handles the case when EWOULDBLOCK and EAGAIN are identical.

Thanks to @twose for the idea.
2020-10-10 14:45:20 +01:00
Gabriel Caruso
14806e0824
Prepare for PHP 8.1
Closes GH-6305.
2020-10-09 11:37:27 +02:00
Sammy Kaye Powers
a9e96a378d
Expose php_during_module_startup() and php_during_module_shutdown()
This can be handy when trying to determine if it is safe to access request globals amongst other things.

Closes GH-6265
2020-10-05 14:01:43 -07:00
Gabriel Caruso
0574c21b50
Prepare for PHP 8.0 RC1 2020-09-30 00:19:10 +02:00
Christoph M. Becker
47a166c837 Fix #78792: zlib.output_compression disabled by Content-Type: image/
Disabling output compression for images has served to fix bug #16109,
where zlib compressed images apparently have caused issues with
Navigator 4.  This shouldn't be an issue with somewhat contemporary
browsers.  Other than that, this is an arbitrary restriction – why
don't we disable the compression for some other media types as well
(e.g. video/* and audio/*)?  All in all, we should leave that decision
to userland.

Closes GH-6198.
2020-09-29 11:30:06 +02:00
Stanislav Malyshev
e14f835d8c Merge branch 'PHP-7.4'
* PHP-7.4:
  Update UPGRADING
  Update UPGRADING
  Update NEWS & UPGRADING
  Do not decode cookie names anymore
  Fix bug #79601 (Wrong ciphertext/tag in AES-CCM encryption for a 12 bytes IV)
2020-09-28 22:55:37 -07:00
Stanislav Malyshev
c4dc080245 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Update UPGRADING
  Update NEWS & UPGRADING
  Do not decode cookie names anymore
  Fix bug #79601 (Wrong ciphertext/tag in AES-CCM encryption for a 12 bytes IV)
2020-09-28 22:54:57 -07:00
Stanislav Malyshev
a9e4321846 Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  Update NEWS & UPGRADING
  Do not decode cookie names anymore
  Fix bug #79601 (Wrong ciphertext/tag in AES-CCM encryption for a 12 bytes IV)
2020-09-28 21:39:34 -07:00
Stanislav Malyshev
6559fe9126 Do not decode cookie names anymore 2020-09-26 23:47:04 -07:00
Christoph M. Becker
ffa57164a8 Clear error flag instead of toggling it
The toggling of the `REPORT_ERRORS` looks fishy, and likely was
intented as clearing.

Closes GH-6190.
2020-09-23 23:26:58 +02:00
Christoph M. Becker
05edf64436 Merge branch 'PHP-7.4' into master
* PHP-7.4:
  Fix #76735: Incorrect message in fopen on invalid mode
2020-09-23 11:14:06 +02:00
Christoph M. Becker
a89ac98f15 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #76735: Incorrect message in fopen on invalid mode
2020-09-23 10:54:59 +02:00
Christoph M. Becker
2576c57a51 Fix #76735: Incorrect message in fopen on invalid mode
We have to log errors in `stream_opener` callbacks to the wrapper's
error log, because otherwise we may pick up an unrelated `errno` or a
most generic message.

Closes GH-6187.
2020-09-23 10:54:06 +02:00
Christoph M. Becker
544dbe8ef9 Merge branch 'PHP-7.4' into master
* PHP-7.4:
  Fix #76943: Inconsistent stream_wrapper_restore() errors
2020-09-22 16:14:03 +02:00
Christoph M. Becker
ff0f6c26c2 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #76943: Inconsistent stream_wrapper_restore() errors
2020-09-22 16:12:37 +02:00
Christoph M. Becker
5ed0602ec6 Fix #76943: Inconsistent stream_wrapper_restore() errors
If restoring of any not registered built-in wrapper is requested, the
function is supposed to fail with a warning, so we have to check this
condition first.

Furthermore, to be able to detect whether a built-in wrapper has been
changed, it is not sufficient to check whether *any* userland wrapper
has been registered, but rather whether the specific wrapper has been
modified.

Closes GH-6183.
2020-09-22 16:11:35 +02:00
Christoph M. Becker
d893404fb9 Merge branch 'PHP-7.4' into master
* PHP-7.4:
  Fix #79423: copy command is limited to size of file it can copy
2020-09-22 13:19:06 +02:00
Christoph M. Becker
f445e9cb93 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #79423: copy command is limited to size of file it can copy
2020-09-22 13:16:59 +02:00
Christoph M. Becker
4000780b3d Fix #79423: copy command is limited to size of file it can copy
Passing `NULL` as `lpFileSizeHigh` to `GetFileSize()` gives wrong
results for files larger than 0xFFFFFFFF bytes.  We fix this by using
`GetFileSizeEx()`, and let the mapping fail, if the file size is too
large for the architecture.

Closes GH-5319.
2020-09-22 13:15:07 +02:00
Christoph M. Becker
3e33e1e86d Check linker compatibility directly from HMODULE
Checking the linker compatibility with extranous `ImageLoad()` calls is
possible, but unnecessary, since the modules are either already loaded
or loaded shortly afterwards, so that we can get the required
information directly from the module handles.  And actually, doing
`ImageLoad()` as well as `LoadLibrary()` leaves a tiny room for a race
condition, because both functions will lookup the module in the search
path, so there is no *guarantee* that both are dealing with the same
module.  Dropping the `ImageLoad()` calls also has the advantage to no
longer face the issue reported in bug #79557.  A very minor additional
advantage is that we no longer have to link against Imagehlp.dll.

Furthermore, there is no need to check for CRT compatibility multiple
times, so we can simplify the signature of `php_win32_crt_compatible`,
and at the same time clean up main.c a bit.

These changes require to change the signature of the exported
`php_win32_image_compatible` and `php_win32_crt_compatible` functions,
which now expect a `HMODULE` and nothing, respectively, instead of the
module name.
2020-09-21 16:25:31 +02:00
Christoph M. Becker
6fa2493789 Merge branch 'PHP-7.4' into master
* PHP-7.4:
  Fix mmap copying
2020-09-21 16:09:17 +02:00
Christoph M. Becker
19c844594e Fix mmap copying
Instead of attempting to map large files into memory at once, we map
chunks of at most `PHP_STREAM_MMAP_MAX` bytes, and repeat that until we
hit the point where `php_stream_seek()` fails (see bug 54902), and copy
the rest of the file by reading and writing small chunks.

We also fix the mapping behavior for zero bytes on Windows, which did
not error (as with `mmap()`), but would have mapped the remaining file.
2020-09-21 16:07:57 +02:00
Sammy Kaye Powers
12306728c5
Add system ID entropy API
The `zend_system_id` is a (true global) system ID that fingerprints a process state. When extensions add engine hooks during MINIT/startup, entropy is added the system ID for each hook. This allows extensions to identify that changes have been made to the engine since the last PHP process restart.

Closes GH-5871
2020-09-18 14:26:44 -07:00
Máté Kocsis
46d22e435f
Change int parameter types to bool when the parameter behaves as bool
Closes GH-6148
2020-09-17 09:38:18 +02:00
Christoph M. Becker
edddddcea8 7.3.24 is next 2020-09-15 10:51:41 +02:00
Nikita Popov
ec3f3002cd Fix observer leak
Make sure to startup observer infrastructure before we register
the first observer...
2020-09-15 10:41:19 +02:00
Benjamin Eberlei
1359a52d5b Rename zend_error_notify APIs to zend_observer_error* 2020-09-14 19:29:14 +02:00
Christoph M. Becker
4d86000541 Merge branch 'PHP-7.4' into master
* PHP-7.4:
  Fix #80067: Omitting the port in bindto setting errors
2020-09-11 14:49:07 +02:00
Christoph M. Becker
e41867888a Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #80067: Omitting the port in bindto setting errors
2020-09-11 14:46:51 +02:00
Christoph M. Becker
dfb3a79914 Fix #80067: Omitting the port in bindto setting errors
A recent commit[1] which fixed a memory leak introduced a regression
regarding the formerly liberal handling of IP addresses to bind to.  We
fix this by reverting that commit, and fix the memory leak where it
actually occurs.  In other words, this fix is less intrusive than the
former fix.

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

Closes GH-6104.
2020-09-11 14:44:12 +02:00
twosee
bd1d11d352 Simplify error type filter
Closes GH-6049.
2020-09-10 17:36:04 +08:00
Dmitry Stogov
4a2ae84188 Add "const". Move constant strings to read-only memory. 2020-09-07 21:35:48 +03:00
Christoph M. Becker
c7cba01b88 Merge branch 'PHP-7.4' into master
* PHP-7.4:
  Fix #80048: Bug #69100 has not been fixed for Windows
2020-09-03 15:46:30 +02:00
Christoph M. Becker
2f4a2a9316 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #80048: Bug #69100 has not been fixed for Windows
2020-09-03 15:45:33 +02:00
Christoph M. Becker
1848ccdae2 Fix #80048: Bug #69100 has not been fixed for Windows
We fix the erroneous length calculation on Windows, too.

Closes GH-6067.
2020-09-03 15:43:19 +02:00
Levi Morrison
66c3e900e2 Add zend_observer API
Closes GH-5857.

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
Co-authored-by: Sammy Powers <sammyk@datadoghq.com>
2020-09-01 09:59:59 -06:00
Nikita Popov
2c15c9ce80 Rehash function table after disabling functions
To perform fast shutdown without full table cleanup we need all
internal functions to be in one continuous chunk. This was
violated when functions were deleted via disable_functions.

This drops the zend_disable_function() API in favor of
zend_disable_functions(), which disables the given list of
functions and performs the necessary rehash afterwards.

Also drop PG(disabled_functions), which is no longer used.
2020-08-28 16:50:07 +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
George Peter Banyard
1b2ec73c1d Drop various unused macros/APIs
Also convert_libmagic_pattern() to return a zend_string*

Closes GH-6029
2020-08-26 12:59:43 +02:00
Christoph M. Becker
ff14b7adad 7.3.23 is next 2020-08-18 09:55:37 +02:00
Derick Rethans
499bf91cd0 Prepare for 7.4.11 2020-08-18 08:06:20 +01:00
Nikita Popov
824541d57e Disable report_zend_debug by default
We might just want to drop this completely, but at least don't
enable it by default. It already gets disabled by a number of
SAPIs, but we should make that the default state.
2020-08-12 10:36:40 +02:00
Nikita Popov
7c3e487289 Fixed bug #65275
Make EG(exit_status) the single source of truth for the exit status,
instead of having two variables that we cannot really keep
synchronized.
2020-08-10 12:40:26 +02:00
Nikita Popov
896dad4c79 Fixed bug #77561
Unconditionally strip shebang lines when using the CLI SAPI,
independently of whether they occur in the primary or non-primary
script. It's unlikely that someone intentionally wants to print
that shebang line when including a script, and this regularly
causes issues when scripts are used in multiple contexts, e.g.
for direct invocation and as a phar bootstrap.
2020-08-10 10:38:33 +02:00
Máté Kocsis
af80d8a14e
Add more argument types to stubs
Closes GH-5943
2020-08-07 12:35:30 +02:00
Nikita Popov
2965c8f868 Prefer strtoll over atoll
Both are specified by C99, but strtoll has specified overflow
behavior while atoll does not, so prefer using it.
2020-08-05 18:40:23 +02:00
Nikita Popov
52047addc7 Only force log startup errors if display_startup_errors disabled
Otherwise this results in duplicate errors.

Closes GH-5941.
2020-08-05 18:17:00 +02:00
Nikita Popov
4cc4f9c00a Use standard types in fopencookie test
Instead of internal __size_t / __off64_t types use ssize_t and off64_t.
This makes it work on musl as well.
2020-08-05 10:39:37 +02:00
Nikita Popov
b0d139456a Use standard types in fopencookie test
Instead of internal __size_t / __off64_t types use ssize_t and off64_t.
This makes it work on musl as well.
2020-08-05 09:45:51 +02:00
Gabriel Caruso
7479ab9f80 Update API version numbers
In preparation for PHP 8.0.
2020-08-04 22:25:28 +02:00
Nikita Popov
0d836a39a7 Revert "Prepare for PHP 8.1"
This reverts commit 1ab4d0e6b7.
This reverts commit a359635cb1.
2020-08-04 22:24:44 +02:00
Gabriel Caruso
a359635cb1
Prepare for PHP 8.1 2020-08-04 18:46:14 +02:00
Gabriel Caruso
1ab4d0e6b7
Update API version numbers
In preparation for PHP 8.0.
2020-08-04 18:07:16 +02:00
Remi Collet
6b8ffdbdeb bump version to 7.2.34-dev 2020-08-04 09:55:29 +02:00