Commit Graph

5699 Commits

Author SHA1 Message Date
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