Commit Graph

1154 Commits

Author SHA1 Message Date
Jakub Zelenka
4a5d13e205
Fix GH-11242: Use dynamic buffer for large length in stream mem copy 2023-07-08 11:43:05 +01:00
Niels Dossche
0b2e6bc2b0 Cache d_type in directory entry 2023-07-07 18:02:32 +02:00
Jakub Zelenka
49fbbea2ea
Fix GH-10406: fgets on a redis socket connection fails on PHP 8.3
This is an alternative implementation for GH-10406 that resets the
has_buffered_data flag after finishing stream read so it does not impact
other ops->read use like for example php_stream_get_line.

Closes GH-11421
2023-06-11 13:27:00 +01:00
Niels Dossche
d22d0e26dc Implement GH-8641: STREAM_NOTIFY_COMPLETED over HTTP never emitted
This adds support for the completed event. Since the read handler could
be entered twice towards the end of the stream we remember what the eof
flag was before reading so we can emit the completed event when the flag
changes to true.

Closes GH-10505.
2023-06-10 19:47:36 +02:00
George Peter Banyard
13ad8ef40b memory stream: fix [-Wanalyzer-deref-before-check]
|  732 |                 ts->mode = mode && mode[0] == 'r' && mode[1] != '+' ? TEMP_STREAM_READONLY : 0;
    |      |                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~

Although mode is already dereference on line 723 in the call to strlen()
2023-06-02 20:33:20 +01:00
iamluc
730f32bad9
Keep the orig_path for xport stream
Closes GH-11113
2023-05-12 15:33:55 +01:00
Niels Dossche
acc940645e
Remove unnecessary NULL assignments after ecalloc in streams (#11209)
ecalloc already zeroes the structure, so writing NULL is not necessary.
2023-05-09 19:46:45 +02:00
Javier Eguiluz
732d92c0e5
[skip ci] Fix various typos and grammar issues (#11143) 2023-04-28 11:05:32 +02:00
Jakub Zelenka
c0b89e064c
Merge branch 'PHP-8.2' 2023-03-30 13:36:14 +01:00
Jakub Zelenka
e80073d3d2
Fix GH-10406: feof() behavior change for UNIX based socket resources
This change restores the old behaviour for the server socket streams
that don't support IO. This is now stored in the stream flags so it can
be later used to do some other decisions and possibly introduce some
better error reporting.

Closes GH-10877
2023-03-30 13:31:46 +01:00
Max Kellermann
413844d626
Zend/zend_types.h: deprecate zend_bool, zend_intptr_t, zend_uintptr_t (#10597)
These types are standard C99.

For compatibility with out-of-tree extensions, keep the typedefs
in main/php.h.
2023-02-18 19:31:28 +00:00
Arnaud Le Blanc
4ec366429e Merge branch 'PHP-8.2'
* PHP-8.2:
  [ci skip] NEWS
  Fix GH-10548: copy() fails on cifs mounts because of incorrect length (cfr_max) specified in streams.c:1584 copy_file_range() (#10551)
2023-02-11 16:30:11 +01:00
Niels Dossche
e787d6c9e6
Fix GH-10548: copy() fails on cifs mounts because of incorrect length (cfr_max) specified in streams.c:1584 copy_file_range() (#10551)
On some filesystems, the copy operation fails if we specify a size
larger than the file size in certain circumstances and configurations.
In those cases EIO will be returned as errno and we will therefore fall
back to other methods.
2023-02-11 16:25:14 +01:00
Arnaud Le Blanc
d49e41925b Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix concurrent testing
  [ci skip] NEWS
  Fix GH-10370: File corruption in _php_stream_copy_to_stream_ex when using copy_file_range (#10440)
2023-02-10 13:32:42 +01:00
Niels Dossche
b4db690cb3
Fix GH-10370: File corruption in _php_stream_copy_to_stream_ex when using copy_file_range (#10440)
copy_file_range can return early without copying all the data. This is
legal behaviour and worked properly, unless the mmap fallback was used.
The mmap fallback would read too much data into the destination,
corrupting the destination file. Furthermore, if the mmap fallback would
fail and have to fallback to the regular file copying mechanism, a
similar issue would occur because both maxlen and haveread are modified.
Furthermore, there was a mmap-resource in one of the failure paths of
the mmap fallback code.
This patch fixes these issues. This also adds regression tests using the
new copy_file_range early-return simulation added in the previous
commit.
2023-02-10 13:08:44 +01:00
Christoph M. Becker
c8955c078a
Revert GH-10220
Cf. <https://github.com/php/php-src/pull/10220#issuecomment-1383739816>.

This reverts commit ecc880f491.
This reverts commit 588a07f737.
This reverts commit f377e15751.
This reverts commit b4ba16fe18.
This reverts commit 694ec1deea.
This reverts commit 6b34de8eba.
This reverts commit aa1cd02a43.
This reverts commit 308fd311ea.
This reverts commit 16203b53e1.
This reverts commit 738fb5ca54.
This reverts commit 9fdbefacd3.
This reverts commit cd4a7c1d90.
This reverts commit 928685eba2.
This reverts commit 01e5ffc85c.
2023-01-16 12:27:33 +01:00
Max Kellermann
16203b53e1 main: add missing includes 2023-01-10 14:19:03 +00:00
Jakub Zelenka
b8d013a48d
Merge branch 'PHP-8.2' 2022-10-23 12:41:51 +01:00
Jakub Zelenka
b732d80329
Fix bug GH-9779: stream_copy_to_stream fail when dest in append mode 2022-10-23 12:40:22 +01:00
Jakub Zelenka
18fe337bae
Fix bug #51056: fread() on blocking stream will block even if data is available
This is applied only on socket connection which already returns
immediately if there is no data in the buffer.
2022-10-16 12:17:47 +01:00
Máté Kocsis
d90ecb9582
Declare main constants in stubs - part 2 (#9714) 2022-10-11 13:48:52 +02:00
Dmitry Stogov
d64aa6f646 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Reset FG(user_stream_current_filename) at the end of request
2022-09-12 11:39:27 +03:00
Dmitry Stogov
f4afa9adc6 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Reset FG(user_stream_current_filename) at the end of request
2022-09-12 11:39:18 +03:00
Dmitry Stogov
d0b3096ff0 Reset FG(user_stream_current_filename) at the end of request
Attempt to fix oss-fuzz #51047
2022-09-12 11:38:31 +03:00
twosee
ef39adb638
Merge branch 'PHP-8.1'
* PHP-8.1:
  Re-fix GH-8409: SSL handshake timeout persistent connections hanging
  Revert "Fix GH-8409: SSL handshake timeout persistent connections hanging"
2022-08-14 20:15:35 +08:00
twosee
14d71957ca
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Re-fix GH-8409: SSL handshake timeout persistent connections hanging
2022-08-14 20:14:57 +08:00
twosee
b8d07451d4
Re-fix GH-8409: SSL handshake timeout persistent connections hanging
This fix is another solution to replace d0527427be, use zend_try and zend_catch to make sure persistent stream will be released when error occurred.

Closes GH-9332.
2022-08-14 20:13:36 +08:00
Jakub Zelenka
897ca85d33
Revert "Fix GH-8409: SSL handshake timeout persistent connections hanging"
This reverts commit d0527427be.

This patch makes Swoole/Swow can not work anymore, because Coroutine will yield to another one during socket operation, EG(record_errors) assertion will always fail, and zend_begin_record_errors() was only used during compile time before.
Note: zend_emit_recorded_errors() and the typo fix are reserved.
2022-08-14 19:41:06 +08:00
Jakub Zelenka
438f692e92
Merge branch 'PHP-8.1' 2022-08-12 17:12:28 +01:00
Jakub Zelenka
d0527427be
Fix GH-8409: SSL handshake timeout persistent connections hanging
This is not actually related to SSL handshake but stream socket creation
which does not clean errors if the error handler is set. This fix
prevents emitting errors until the stream is freed.
2022-08-12 17:09:24 +01:00
Jakub Zelenka
80197c59ec
Merge branch 'PHP-8.1' 2022-08-07 14:22:33 +01:00
Jakub Zelenka
c9fa98a174
Merge branch 'PHP-8.0' into PHP-8.1 2022-08-07 14:21:39 +01:00
Jakub Zelenka
d9ff5e079f
Fix GH-8472: stream_socket_accept result may have incorrect metadata 2022-08-07 14:17:38 +01:00
Jakub Zelenka
1a9e6895f1
Fix #65069: GlobIterator incorrect handling of open_basedir check
This PR changes the glob stream wrapper so it impacts "glob://"
streamsas well. The idea is to do a check for each found path instead
of the pattern which was not working correctly.
2022-07-28 11:42:42 +01:00
Jakub Zelenka
0a4a55fd44
Allow to not close stream on rscr dtor in php cli sapi 2022-07-18 10:58:50 +01:00
Rowan Tommins
af15923bc3
Extend deprecation notices to is_callable($foo) and callable $foo
Implements https://wiki.php.net/rfc/partially-supported-callables-expand-deprecation-notices
so that uses of "self" and "parent" in is_callable() and callable
type constraints now raise a deprecation notice, independent of the
one raised when and if the callable is actually invoked.

A new flag is added to the existing check_flags parameter of
zend_is_callable / zend_is_callable_ex, for use in internal calls
that would otherwise repeat the notice multiple times. In particular,
arguments to internal function calls are checked first based on
arginfo, and then again during ZPP, so the former suppresses the
deprecation notice.

Some existing tests which raised this deprecation have been updated
to avoid the syntax, but the existing version retained for maximum
regression coverage until it is made an error.

With thanks to Juliette Reinders Folmer for the RFC and initial
investigation.

Closes GH-8823.
2022-07-14 17:07:42 +02:00
David Carlier
7ceae66182 streams/xp_socket: fix clang build error with enum usage on bool condition.
Fix targeted for oses defining those flags as enums (like Linux/glibc).

`error: converting the enum constant to a boolean [-Werror,-Wint-in-bool-context]
                                } else if ((!sslsock->ssl_active && value == 0 && (MSG_DONTWAIT || !sslsock->s.is_blocked)) ||`

Closes #8895.
2022-06-30 05:45:33 +01:00
Max Kellermann
e2bd3b1e99 main/streams/plain_wrapper: skip lseek(SEEK_CUR) for newly opened files
A file that has just been opened is known to be at offset zero, and
the lseek(SEEK_CUR) system call to determine the current offset can be
skipped.

Closes #8540.
2022-06-29 18:11:01 +01:00
Max Kellermann
2d986310f1 streams/xp_socket: eliminate poll() when MSG_DONTWAIT is available
If there is a zero timeout and MSG_DONTWAIT is available (or the
socket is non-blocking), the poll() call is not necessary, and we can
just call recv() right away.

Before this change:

 poll([{fd=4, events=POLLIN|POLLPRI|POLLERR|POLLHUP}], 1, 0) = 0 (Timeout)
 poll([{fd=4, events=POLLIN|POLLERR|POLLHUP}], 1, 60000) = 1 ([{fd=4, revents=POLLIN}])
 recvfrom(4, "HTTP/1.1 301 Moved Permanently\r\n"..., 8192, MSG_DONTWAIT, NULL, NULL) = 348
 poll([{fd=4, events=POLLIN|POLLPRI|POLLERR|POLLHUP}], 1, 0) = 1 ([{fd=4, revents=POLLIN}])
 recvfrom(4, "", 1, MSG_PEEK, NULL, NULL) = 0

After this change:

 recvfrom(4, 0x7ffe0cc719a0, 1, MSG_PEEK|MSG_DONTWAIT, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
 poll([{fd=4, events=POLLIN|POLLERR|POLLHUP}], 1, 60000) = 1 ([{fd=4, revents=POLLIN}])
 recvfrom(4, "HTTP/1.1 301 Moved Permanently\r\n"..., 8192, MSG_DONTWAIT, NULL, NULL) = 348
 recvfrom(4, "", 1, MSG_PEEK|MSG_DONTWAIT, NULL, NULL) = 0

The first poll() is replaced by recvfrom(), and the third poll() is
omitted completely.

ext/openssl/xp_ssl: eliminate poll() when MSG_DONTWAIT is available

If there is a zero timeout and MSG_DONTWAIT is available (or the
socket is non-blocking), the poll() call is not necessary, and we can
just call recv() right away.

Closes GH-8092.
2022-06-18 19:44:32 +01:00
Dmitry Stogov
2df805da7e Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix use after free
2022-06-14 12:50:16 +03:00
Dmitry Stogov
6797f338a7 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix use after free
2022-06-14 12:45:12 +03:00
Dmitry Stogov
0b8e471b3c Fix use after free
This fixes oss-fuzz #47997
2022-06-14 12:44:37 +03:00
Ilija Tovilo
c019421912
Fix regression from GH-8587 (#8615)
* Fix regression from GH-8587

Streams hold a reference to the stream wrapper. User stream wrappers
must not be released until the streams themselves are closed.

* Add test for directories
2022-06-09 13:49:41 +02:00
Michael Voříšek
fb1c7eff04
Fix some level 1 MSVC compiler warnings on x86
See GH-8479.
2022-05-24 13:05:16 +02:00
Ilija Tovilo
a5a89cc222
Fix stream_wrapper_unregister() resource leak
Closes GH-8548
Closes GH-8587
2022-05-21 18:49:43 +02:00
Max Kellermann
fa6d97db5d
main/streams/streams: use copy_file_range() on Linux (#8413)
copy_file_range() is a Linux-specific system call which allows
efficient copying between two file descriptors, eliminating the need
to transfer data from the kernel to userspace and back.  For
networking file systems like NFS and Ceph, it even eliminates copying
data to the client, and local filesystems like Btrfs and XFS can
create shared extents.
2022-04-23 13:32:05 +01:00
Christoph M. Becker
30b2398860
Merge branch 'PHP-8.1'
* PHP-8.1:
  Preserve file-position when php://temp switches to temporary file
2022-04-11 12:45:48 +02:00
Christoph M. Becker
e3a5e424f6
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Preserve file-position when php://temp switches to temporary file
2022-04-11 12:44:56 +02:00
Bernd Holzmüller
84c18f9f04
Preserve file-position when php://temp switches to temporary file
Closes GH-8333.
2022-04-11 12:31:22 +02: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
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
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
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
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
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
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
Patrick Allaert
aff365871a Fixed some spaces used instead of tabs 2021-06-29 11:30:26 +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
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
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
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
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
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
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
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
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
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
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