summaryrefslogtreecommitdiff
path: root/main/streams/plain_wrapper.c
Commit message (Collapse)AuthorAgeFilesLines
* Suppress stream errors in mysqlndNikita Popov2020-11-301-2/+6
| | | | | | | | | | | | | | | | mysqlnd currently sets error_reporting=0 to suppress errors while writing to streams. Unfortunately these errors are still visible to userland error handlers, which is a source of confusion. See for example https://bugs.php.net/bug.php?id=80412. Instead add a stream flag that suppresses the emission of read/write errors in the first place, and set it in mysqlnd. I think it might be useful to have this option for userland as well in the future, but for now this is just an internal mechanism. Closes GH-6458.
* Merge branch 'PHP-7.4' into masterChristoph M. Becker2020-09-231-3/+1
|\ | | | | | | | | * PHP-7.4: Fix #76735: Incorrect message in fopen on invalid mode
| * Merge branch 'PHP-7.3' into PHP-7.4Christoph M. Becker2020-09-231-3/+1
| |\ | | | | | | | | | | | | * PHP-7.3: Fix #76735: Incorrect message in fopen on invalid mode
| | * Fix #76735: Incorrect message in fopen on invalid modeChristoph M. Becker2020-09-231-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | We have to log errors in `stream_opener` callbacks to the wrapper's error log, because otherwise we may pick up an unrelated `errno` or a most generic message. Closes GH-6187.
* | | Merge branch 'PHP-7.4' into masterChristoph M. Becker2020-09-221-1/+17
|\ \ \ | |/ / | | | | | | | | | * PHP-7.4: Fix #79423: copy command is limited to size of file it can copy
| * | Merge branch 'PHP-7.3' into PHP-7.4Christoph M. Becker2020-09-221-1/+17
| |\ \ | | |/ | | | | | | | | | * PHP-7.3: Fix #79423: copy command is limited to size of file it can copy
| | * Fix #79423: copy command is limited to size of file it can copyChristoph M. Becker2020-09-221-1/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | Passing `NULL` as `lpFileSizeHigh` to `GetFileSize()` gives wrong results for files larger than 0xFFFFFFFF bytes. We fix this by using `GetFileSizeEx()`, and let the mapping fail, if the file size is too large for the architecture. Closes GH-5319.
* | | Merge branch 'PHP-7.4' into masterChristoph M. Becker2020-09-211-0/+5
|\ \ \ | |/ / | | | | | | | | | * PHP-7.4: Fix mmap copying
| * | Fix mmap copyingChristoph M. Becker2020-09-211-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | Merge branch 'PHP-7.4' into masterChristoph M. Becker2020-09-031-8/+4
|\ \ \ | |/ / | | | | | | | | | * PHP-7.4: Fix #80048: Bug #69100 has not been fixed for Windows
| * | Merge branch 'PHP-7.3' into PHP-7.4Christoph M. Becker2020-09-031-8/+4
| |\ \ | | |/ | | | | | | | | | * PHP-7.3: Fix #80048: Bug #69100 has not been fixed for Windows
| | * Fix #80048: Bug #69100 has not been fixed for WindowsChristoph M. Becker2020-09-031-8/+4
| | | | | | | | | | | | | | | | | | We fix the erroneous length calculation on Windows, too. Closes GH-6067.
* | | Support socketpairs in proc_open()Martin Schröder2020-07-141-0/+5
| | | | | | | | | | | | Closes GH-5777.
* | | Review the usage of apostrophes in error messagesMáté Kocsis2020-07-101-1/+1
| | | | | | | | | | | | Closes GH-5590
* | | Correct comment in plain_wrapper.c (refers to microseconds, not milliseconds)Alex Dowad2020-06-241-1/+1
| | |
* | | Fix expression warnings and break warningstwosee2020-06-071-0/+1
| | | | | | | | | | | | Close GH-5675.
* | | Fix [-Wundef] warning in streams implementationGeorge Peter Banyard2020-05-121-9/+9
| | |
* | | Promote invalid mode/unknow option from Warning to ValueError for plain streams.George Peter Banyard2020-02-041-2/+2
| | | | | | | | | | | | Closes GH-5076
* | | 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.
* | | Fix #78880: Another bunch of spelling errorsMáté Kocsis2020-01-161-1/+1
| | |
* | | 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.
* | | Remove mention of PHP major version in Copyright headersGabriel Caruso2019-09-251-2/+0
|/ / | | | | | | Closes GH-4732.
* | 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.
* | Throw notice for plain wrapper fread/fwrite errorsNikita Popov2019-07-251-4/+17
| | | | | | | | Similar to what is done for socket read/write errors.
* | Report errors from stream read and write operationsNikita Popov2019-07-221-11/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | 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
| | | * year++Xinchen Hui2018-01-021-1/+1
| | | |
| | * | 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
|/ / /
* | | Simplify assignment on 64-bitAnatol Belski2018-11-171-2/+1
| | |
* | | Fix error conditionAnatol Belski2018-10-301-2/+2
| | |
* | | Fixed bug #77081 ftruncate() changes seek pointer in c modeAnatol Belski2018-10-301-3/+4
| | |
* | | Make php_plain_files_wrapper to be writable (workaround for swoole)Dmitry Stogov2018-10-241-1/+2
| | |
* | | Fixed bug #76803 ftruncate changes file pointerAnatol Belski2018-08-281-0/+9
| | |
* | | 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.
* | | Fixed bug #76422 ftruncate fails on files > 2GBAnatol Belski2018-06-091-0/+22
| | |
* | | Use zend_string_release_ex() instread of zend_string_release() in places, ↵Dmitry Stogov2018-05-281-2/+2
| | | | | | | | | | | | where we sure about string persistence.
* | | year++Xinchen Hui2018-01-021-1/+1
| | |
* | | Turn "php_stream_wrapper"s into constantsDmitry Stogov2017-12-141-3/+3
| | | | | | | | | | | | Keep non-constant "php_stream_wrapper"s in API functions and callbacks for compatibility.
* | | Move constants into read-only data segmentDmitry Stogov2017-12-141-2/+3
|/ /