summaryrefslogtreecommitdiff
path: root/main/streams
Commit message (Collapse)AuthorAgeFilesLines
...
* | | Merge branch 'PHP-7.4'Nikita Popov2019-12-301-0/+3
|\ \ \ | |/ / | | | | | | | | | * PHP-7.4: Properly propagate url_stat exceptions during include
| * | Properly propagate url_stat exceptions during includeNikita Popov2019-12-301-0/+3
| | | | | | | | | | | | | | | Make sure we abort operations early, and that we don't emit additional warnings or errors if an exception has been thrown.
* | | Use RETURN_THROWS() during ZPP in main, sapi, win32, and ZendMáté Kocsis2019-12-301-3/+3
| | |
* | | Merge branch 'PHP-7.4'Nikita Popov2019-12-201-17/+23
|\ \ \ | |/ / | | | | | | | | | * PHP-7.4: Fixed bug #79000
| * | Fixed bug #79000Nikita Popov2019-12-201-17/+23
| | | | | | | | | | | | | | | | | | | | | | | | Don't report EAGAIN/EWOULDBLOCK as errors for fwrite on non-blocking socket streams. This matches behavior for fread, as well as behavior for plain file streams. Closes GH-5026.
* | | Merge branch 'PHP-7.4'Christoph M. Becker2019-12-021-14/+20
|\ \ \ | |/ / | | | | | | | | | * PHP-7.4: Fix #78883: fgets(STDIN) fails on Windows
| * | Fix #78883: fgets(STDIN) fails on WindowsChristoph M. Becker2019-12-021-14/+20
| | | | | | | | | | | | | | | | | | | | | | | | We add the `is_seekable` member to `php_stdio_stream_data`, and prefer that over `is_pipe`, since the latter is simply a misnomer. We keep `is_pipe` for now for Windows only, though, because we need special support for pipes there. We also fix the misaligned bitfield which formerly took 33 bit.
* | | Merge branch 'PHP-7.4'Nikita Popov2019-10-311-6/+0
|\ \ \ | |/ / | | | | | | | | | * PHP-7.4: Fix bug #77930: Remove mmap limit
| * | Fix bug #77930: Remove mmap limitNikita Popov2019-10-311-6/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | First, the limitation already doesn't trigger if you copy the whole file (i.e. use copy() or stream_copy_to_stream() and don't specify a length). This happens because length will be 0 at the time of the check and only later calculated based on the file size. This means that we're already completely blowing the length limit for what is likely the most common case, and it doesn't seem like anyone complained about that. Second, the premise of the code comment ("to avoid runaway swapping") seems incorrect to me. Because this performs a file-backed non-private mmap, no swap backing is needed for the mapping. Concerns over "memory usage" are also misplaced, as this is a virtual mapping.
* | | Don't use chunking for stream writesNikita Popov2019-10-301-7/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We're currently splitting up large writes into 8K size chunks, which adversely affects I/O performance in some cases. Splitting up writes doesn't make a lot of sense, as we already must have a backing buffer, so there is no memory/performance tradeoff to be made here. This change disables the write chunking at the stream layer, but retains the current retry loop for partial writes. In particular network writes will typically only write part of the data for large writes, so we need to keep the retry loop to preserve backwards compatibility. If issues due to this change turn up, chunking should be reintroduced at lower levels where it is needed to avoid issues for specific streams, rather than unnecessarily enforcing it for all streams.
* | | Merge branch 'PHP-7.4'Remi Collet2019-10-111-7/+8
|\ \ \ | |/ / | | | | | | | | | | | | * PHP-7.4: NEWS Fix #78662: stream_write bad error detection
| * | Fix #78662: stream_write bad error detectionRemi Collet2019-10-111-7/+8
| | |
* | | Merge branch 'PHP-7.4'Nikita Popov2019-10-101-2/+6
|\ \ \ | |/ /
| * | Also check for exception after stream_eofNikita Popov2019-10-101-2/+6
| | |
* | | Merge branch 'PHP-7.4'Nikita Popov2019-10-101-18/+19
|\ \ \ | |/ /
| * | Report error if stream_read is not implementedNikita Popov2019-10-101-18/+19
| | | | | | | | | | | | | | | We need to return -1 in this case. Slightly restructure the code to avoid unnecessary conditions.
* | | Merge branch 'PHP-7.4'Nikita Popov2019-10-081-1/+7
|\ \ \ | |/ /
| * | Merge branch 'PHP-7.3' into PHP-7.4Nikita Popov2019-10-081-1/+7
| |\ \ | | |/
| | * Check for exception after applying stream filtersNikita Popov2019-10-081-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | This makes the stream opening actually fail, and avoids assertion failures when we tokenize with EG(exception) set. Also avoid throwing an additional warning after an exception has already been thrown.
* | | Merge branch 'PHP-7.4'Joe Watkins2019-10-032-6/+0
|\ \ \ | |/ / | | | | | | | | | * PHP-7.4: Fix #76859 stream_get_line skips data if used with data-generating filter
| * | Merge branch 'PHP-7.3' into PHP-7.4Joe Watkins2019-10-032-6/+0
| |\ \ | | |/ | | | | | | | | | * PHP-7.3: Fix #76859 stream_get_line skips data if used with data-generating filter
| | * Merge branch 'PHP-7.2' into PHP-7.3Joe Watkins2019-10-032-6/+0
| | |\ | | | | | | | | | | | | | | | | * PHP-7.2: Fix #76859 stream_get_line skips data if used with data-generating filter
| | | * Fix #76859 stream_get_line skips data if used with data-generating filterKonstantin Kopachev2019-10-032-6/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | stream_get-line repeatedly calls php_stream_fill_read_buffer until enough data is accumulated in buffer. However, when stream contains filters attached to it, then each call to fill buffer essentially resets buffer read/write pointers and new data is written over old. This causes stream_get_line to skip parts of data from stream This patch fixes such behavior, so fill buffer call will append.
* | | | Remove unused mmap_file + mmap_len from basic_globalsNikita Popov2019-09-271-1/+1
| | | |
* | | | Remove mention of PHP major version in Copyright headersGabriel Caruso2019-09-2518-36/+0
|/ / / | | | | | | | | | Closes GH-4732.
* | | Fixed bug #78506Nikita Popov2019-09-111-18/+16
| | |
* | | Fix pipe detection and stream position handlingNikita Popov2019-09-051-31/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are two related changes here: 1. Also check for S_ISCHR/FILE_TYPE_CHAR when checking for pipes, so that we detect ttys as well, which are also not seekable. 2. Always set position=-1 (i.e. ftell will return false) when a pipe is detected. Previously position=0 was sometimes used, depending on whether we're on Windows/Linux and whether the FD or FILE codepath was used.
* | | Replace strncat in filter implementationNikita Popov2019-08-231-2/+3
| | | | | | | | | | | | | | | In this case we already know exactly where we need to write, no need to use strncat at all.
* | | Fixed bug #78396Nikita Popov2019-08-121-1/+1
| | |
* | | Merge branch 'PHP-7.3' into PHP-7.4Nikita Popov2019-07-291-1/+6
|\ \ \ | |/ /
| * | Merge branch 'PHP-7.2' into PHP-7.3Nikita Popov2019-07-291-1/+6
| |\ \ | | |/
| | * Fix bug #78326Albert Casademont2019-07-291-1/+6
| | | | | | | | | | | | | | | Similar to what fread() does, truncate the stream_get_contents() result if the original buffer was way too large.
* | | Throw notice for plain wrapper fread/fwrite errorsNikita Popov2019-07-252-5/+20
| | | | | | | | | | | | Similar to what is done for socket read/write errors.
* | | Report errors from stream read and write operationsNikita Popov2019-07-226-108/+176
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The php_stream_read() and php_stream_write() functions now return an ssize_t value, with negative results indicating failure. Functions like fread() and fwrite() will return false in that case. As a special case, EWOULDBLOCK and EAGAIN on non-blocking streams should not be regarded as error conditions, and be reported as successful zero-length reads/writes instead. The handling of EINTR remains unclear and is internally inconsistent (e.g. some code-paths will automatically retry on EINTR, while some won't). I'm landing this now to make sure the stream wrapper ops API changes make it into 7.4 -- however, if the user-facing changes turn out to be problematic we have the option of clamping negative returns to zero in php_stream_read() and php_stream_write() to restore the old behavior in a relatively non-intrusive manner.
* | | Merge branch 'PHP-7.3' into PHP-7.4Nikita Popov2019-07-171-9/+6
|\ \ \ | |/ /
| * | Merge branch 'PHP-7.2' into PHP-7.3Nikita Popov2019-07-171-9/+6
| |\ \ | | |/
| | * Fixed bug #69100Nikita Popov2019-07-171-9/+6
| | |
* | | Avoid duplicate fstat() for includesNikita Popov2019-07-171-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | By adding a flag to avoid forced fstat for includes. The two fstats will happen back to back and we don't care about a possible invalidation. I was hoping to move this higher up in the stack and make the ISREG check somewhere in fsizer of fixup, but this doesn't really seem to be possible. E.g. an FP stdin handle will not be a regular file but of course needs to be allowed. Additionally custom stream wrappers may not implement this functionality.
* | | Fix use-after-free in stream freeing during shutdownNikita Popov2019-06-272-8/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Streams will be freed in an unpredictable order during shutdown. Ignore explicit calls to php_stream_close() entirely to avoid use-after-free -- instead let the stream resource destructor deal with it. We have to account for a few special cases: * Enclosed streams should be freed, as the resource destructor will forward to the enclosing stream. * Stream cookies also directly free streams, because we delegate to the cookie destruction if one exists. * Mysqlnd also directly frees streams, because it explicitly removes stream resources (because mysqlnd!)
* | | Remove copy argument from php_glob_stream_get_path/patternNikita Popov2019-06-192-16/+8
| | | | | | | | | | | | This is unused, and shouldn't be part of the API.
* | | Avoid memcpy UB in streamsNikita Popov2019-06-191-1/+3
| | |
* | | Allow exceptions in __toString()Nikita Popov2019-06-051-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | RFC: https://wiki.php.net/rfc/tostring_exceptions And convert some object to string conversion related recoverable fatal errors into Error exceptions. Improve exception safety of internal code performing string conversions.
* | | Enable TLS 1.3 by defaultJakub Zelenka2019-04-281-7/+7
| | |
* | | Added tls 1.3 support for PHPcodarrenvelvindron2019-04-281-0/+2
| | |
* | | Use readdir() instead of readdir_r()Nikita Popov2019-04-111-4/+3
| | | | | | | | | | | | | | | | | | readdir_r() is deprecated in modern glibc versions. readdir() is thread safe in practice, as long as there are no concurrent accesses on the *same* directory stream.
* | | Merge branch 'PHP-7.3' into PHP-7.4Stanislav Malyshev2019-03-041-18/+35
|\ \ \ | |/ / | | | | | | | | | * PHP-7.3: Fix bug #77630 - safer rename() procedure
| * | Merge branch 'PHP-7.2' into PHP-7.3Stanislav Malyshev2019-03-041-18/+35
| |\ \ | | |/ | | | | | | | | | * PHP-7.2: Fix bug #77630 - safer rename() procedure
| | * Merge branch 'PHP-7.1' into PHP-7.2Stanislav Malyshev2019-03-041-18/+35
| | |\ | | | | | | | | | | | | | | | | * PHP-7.1: Fix bug #77630 - safer rename() procedure
| | | * Fix bug #77630 - safer rename() procedureStanislav Malyshev2019-03-041-17/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | In order to rename safer, we do the following: - set umask to 077 (unfortunately, not TS, so excluding ZTS) - chown() first, to set proper group before allowing group access - chmod() after, even if chown() fails
| | | * Sync leading and final newlines in source code filesPeter Kokot2018-10-142-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds missing newlines, trims multiple redundant final newlines into a single one, and trims redundant leading newlines. According to POSIX, a line is a sequence of zero or more non-' <newline>' characters plus a terminating '<newline>' character. [1] Files should normally have at least one final newline character. C89 [2] and later standards [3] mention a final newline: "A source file that is not empty shall end in a new-line character, which shall not be immediately preceded by a backslash character." Although it is not mandatory for all files to have a final newline fixed, a more consistent and homogeneous approach brings less of commit differences issues and a better development experience in certain text editors and IDEs. [1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206 [2] https://port70.net/~nsz/c/c89/c89-draft.html#2.1.1.2 [3] https://port70.net/~nsz/c/c99/n1256.html#5.1.1.2