summaryrefslogtreecommitdiff
path: root/main/streams/streams.c
Commit message (Collapse)AuthorAgeFilesLines
* 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.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.
* | | 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)
* | Merge branch 'PHP-7.2'Sara Golemon2017-11-131-2/+5
|\ \ | |/ | | | | | | * PHP-7.2: Bugfix#75515 php://streams behaving greedily
| * Bugfix#75515 php://streams behaving greedilySara Golemon2017-11-131-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | 5060fc23 attempted to fix #68948 by treating all non-uri streams as non-blocking, however php://fd/* streams (which includes stdin) may block if the other end of the IPC isn't finished. This represents a partial revert to the pre RC6 state, but includes an escape hatch for php://memory and php://temp streams which are local to the current process. This also restores stream_set_chunk_size test to previous state.
* | Merge branch 'PHP-7.2'Sara Golemon2017-11-061-1/+1
|\ \ | |/ | | | | | | * PHP-7.2: Fixes #68948 related to a BC break introduced by #68532 fix.
| * Fixes #68948 related to a BC break introduced by #68532 fix.Simon JAILLET2017-11-061-1/+1
| |
* | Fixed memory leaksDmitry Stogov2017-11-021-1/+6
| |
* | Persistent resources are "thread-local".Dmitry Stogov2017-11-011-6/+1
| | | | | | | | Register persistent resources through new functions zend_register_persistent_resource()/zend_register_persistent_resource_ex().
* | Use interned strings for persistent stream wrappers and filtersDmitry Stogov2017-10-311-7/+5
| |
* | Merge branch 'master' into rc_debugDmitry Stogov2017-10-271-1/+1
|\ \ | | | | | | | | | | | | | | | | | | * master: Use per-request heap instead of system one Extend zend_register_class_alias_ex() with additional argument to allow creating persistent or per-request aliases Makrk persistent resources and references with GC_PERSISTENT flag
| * | Use per-request heap instead of system oneDmitry Stogov2017-10-271-1/+1
| | |
* | | Encapsulate reference-counting primitives.Dmitry Stogov2017-10-271-3/+3
|/ / | | | | | | | | | | Prohibit direct update of GC_REFCOUNT(), GC_SET_REFCOUNT(), GC_ADDREF() and GC_DELREF() shoukf be instead. Added mactros to validate reference-counting (disabled for now). These macros are going to be used to eliminate race-condintions during reference-counting on data shared between threads.
* | Move cwd_state and path related routines to size_tAnatol Belski2017-07-271-1/+1
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Having `int` there is no real profit in the size or speed, while unsigned improves security and overall integration. ZPP supplied strings can be then accepted directly and structs can be still handled with smaller unsigned types for size reasons, which is safe. Yet some related places are to go. basic move tsrm_realpath_r to size_t fix conditions and sync with affected places touch ocurrences of php_sys_readlink usage follow up on phar path handling remove duplicated check move zend_resolve_path and related pieces to size_t touch yet resolve path related places remove cast missing pieces missing piece yet cleanups for php_sys_readlink for ssize_t fix wrong return
* Keep resource of enclosing stream, because it may be referenced from other ↵Dmitry Stogov2017-07-191-3/+2
| | | | | | place(s). This fixes valgrind warnings on Zend/tests/type_declarations/scalar_basic.phpt
* shutdown_executor() refactoring (reuse opcache fast request shutdown code)Dmitry Stogov2017-06-221-30/+0
|
* Merge branch 'PHP-7.1'Bob Weinand2017-03-141-0/+2
|\
| * Merge branch 'PHP-7.0' into PHP-7.1Bob Weinand2017-03-141-0/+2
| |\
| | * Fix stream context changes leaking into copies of previous contextBob Weinand2017-03-141-0/+2
| | |
| | * Update copyright headers to 2017Sammy Kaye Powers2017-01-041-1/+1
| | |
| * | Update copyright headers to 2017Sammy Kaye Powers2017-01-041-1/+1
| | |
* | | Interned strings unification for TS/NTSAnatol Belski2017-03-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Hereby, interned strings are supported in thread safe PHP. The patch implements two types of interned strings - interning per process, strings are not freed till process end - interning per request, strings are freed at request end There is no runtime interning. With Opcache, all the permanent iterned strings are copied into SHM on startup, additional copying into SHM might happen on demand.