summaryrefslogtreecommitdiff
path: root/main/streams/streams.c
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'PHP-7.4' into masterChristoph M. Becker2020-09-211-17/+36
|\ | | | | | | | | * PHP-7.4: Fix mmap copying
| * Fix mmap copyingChristoph M. Becker2020-09-211-17/+36
| | | | | | | | | | | | | | | | | | | | 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.
* | ValueError for empty path in stream codeGeorge Peter Banyard2020-07-311-1/+1
| | | | | | | | Closes GH-5902
* | Remove proto comments from C filesMax Semenik2020-07-061-10/+5
| | | | | | | | Closes GH-5758
* | Fix expression warnings and break warningstwosee2020-06-071-3/+3
| | | | | | | | Close GH-5675.
* | Merge branch 'PHP-7.4'Nikita Popov2020-04-141-0/+6
|\ \ | |/ | | | | | | * PHP-7.4: Fixed bug #79468
| * Merge branch 'PHP-7.3' into PHP-7.4Nikita Popov2020-04-141-0/+6
| |\ | | | | | | | | | | | | * PHP-7.3: Fixed bug #79468
| | * Fixed bug #79468dinosaur2020-04-141-0/+6
| | | | | | | | | | | | Close the stream filter resources when removing them from the stream.
* | | Merge branch 'PHP-7.4'Nikita Popov2020-01-231-2/+9
|\ \ \ | |/ / | | | | | | | | | | | | * PHP-7.4: Fixed bug #78902 Add unit test for bug #78902
| * | Merge branch 'PHP-7.3' into PHP-7.4Nikita Popov2020-01-231-2/+9
| |\ \ | | |/ | | | | | | | | | | | | * PHP-7.3: Fixed bug #78902 Add unit test for bug #78902
| | * Fixed bug #78902liudaixiao2020-01-231-2/+9
| | |
* | | Make error messages more consistent by fixing capitalizationMáté Kocsis2020-01-171-4/+4
| | | | | | | | | | | | Closes GH-5066 As a first step, let's capitalize their initial letter when it is applicable.
* | | 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.
* | | 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'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-031-4/+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-031-4/+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-031-4/+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-031-4/+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-251-2/+0
|/ / / | | | | | | | | | Closes GH-4732.
* | | Fixed bug #78506Nikita Popov2019-09-111-18/+16
| | |
* | | 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-251-1/+3
| | | | | | | | | | | | Similar to what is done for socket read/write errors.
* | | Report errors from stream read and write operationsNikita Popov2019-07-221-66/+115
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | Fix use-after-free in stream freeing during shutdownNikita Popov2019-06-271-6/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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!)
* | | Avoid memcpy UB in streamsNikita Popov2019-06-191-1/+3
| | |
* | | Merge branch 'PHP-7.3' into PHP-7.4Nikita Popov2019-02-111-0/+2
|\ \ \ | |/ /
| * | Merge branch 'PHP-7.2' into PHP-7.3Nikita Popov2019-02-111-0/+2
| |\ \ | | |/
| | * Fix #77552: Uninitialized buffer in stat functionsjohnstevenson2019-02-111-0/+2
| | |
| | * year++Xinchen Hui2018-01-021-1/+1
| | |
* | | Remove local variablesPeter Kokot2019-02-031-9/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch removes the so called local variables defined per file basis for certain editors to properly show tab width, and similar settings. These are mainly used by Vim and Emacs editors yet with recent changes the once working definitions don't work anymore in Vim without custom plugins or additional configuration. Neither are these settings synced across the PHP code base. A simpler and better approach is EditorConfig and fixing code using some code style fixing tools in the future instead. This patch also removes the so called modelines for Vim. Modelines allow Vim editor specifically to set some editor configuration such as syntax highlighting, indentation style and tab width to be set in the first line or the last 5 lines per file basis. Since the php test files have syntax highlighting already set in most editors properly and EditorConfig takes care of the indentation settings, this patch removes these as well for the Vim 6.0 and newer versions. With the removal of local variables for certain editors such as Emacs and Vim, the footer is also probably not needed anymore when creating extensions using ext_skel.php script. Additionally, Vim modelines for setting php syntax and some editor settings has been removed from some *.phpt files. All these are mostly not relevant for phpt files neither work properly in the middle of the file.
* | | Remove yearly range from copyright noticeZeev Suraski2019-01-301-1/+1
| | |
* | | Replace zend_hash_apply... with ZEND_HASH_FOREACH...Dmitry Stogov2018-12-191-1/+5
|/ /
* | Remove unused Git attributes identPeter Kokot2018-07-251-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The $Id$ keywords were used in Subversion where they can be substituted with filename, last revision number change, last changed date, and last user who changed it. In Git this functionality is different and can be done with Git attribute ident. These need to be defined manually for each file in the .gitattributes file and are afterwards replaced with 40-character hexadecimal blob object name which is based only on the particular file contents. This patch simplifies handling of $Id$ keywords by removing them since they are not used anymore.
* | Avoid useless stream buffer copying and workaround with chunk_size manipulation.Dmitry Stogov2018-06-141-1/+3
| |
* | Removed "dead" code (zend_hash_update() never fails)Dmitry Stogov2018-06-011-4/+2
| |
* | Use zend_string_release_ex() instread of zend_string_release() in places, ↵Dmitry Stogov2018-05-281-6/+6
| | | | | | | | where we sure about string persistence.
* | year++Xinchen Hui2018-01-021-1/+1
| |
* | Use cheaper APIXinchen Hui2017-12-181-1/+1
| |
* | Use known string "file" in stream layerMarkus Staab2017-12-161-1/+1
| |
* | Turn "php_stream_wrapper"s into constantsDmitry Stogov2017-12-141-5/+5
| | | | | | | | Keep non-constant "php_stream_wrapper"s in API functions and callbacks for compatibility.
* | Move constants into read-only data segmentDmitry Stogov2017-12-141-1/+1
| |
* | Avoid strings duplication (zend_hash* and printf may work with non zero ↵Dmitry Stogov2017-11-301-8/+7
| | | | | | | | terminated strings)