diff options
author | Michael Wallner <mike@php.net> | 2013-12-06 10:29:24 +0100 |
---|---|---|
committer | Michael Wallner <mike@php.net> | 2013-12-06 10:29:24 +0100 |
commit | b5f5bff965c1a27a4820d0129d61f80ef8894e38 (patch) | |
tree | a443003ac2871d7b498523e9f825d801c04ae478 | |
parent | 098d2a5d0ff6353602654a9872c76c5811277546 (diff) | |
download | php-git-b5f5bff965c1a27a4820d0129d61f80ef8894e38.tar.gz |
Fixed bug #61645 (fopen and O_NONBLOCK)
if a mode like "rn" was passed to fopen(), then
php_stream_parse_fopen_modes() would assign O_WRONLY to
flags, because O_NONBLOCK tainted flags for the r/w/+ check
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | main/streams/plain_wrapper.c | 12 |
2 files changed, 8 insertions, 5 deletions
@@ -4,6 +4,7 @@ PHP NEWS - Core: . Added validation of class names in the autoload process. (Dmitry) + . Fixed bug #61645 (fopen and O_NONBLOCK). (Mike) - Date: . Fixed bug #66060 (Heap buffer over-read in DateInterval). (Remi) diff --git a/main/streams/plain_wrapper.c b/main/streams/plain_wrapper.c index 4ee81506b3..c188763f53 100644 --- a/main/streams/plain_wrapper.c +++ b/main/streams/plain_wrapper.c @@ -78,11 +78,7 @@ PHPAPI int php_stream_parse_fopen_modes(const char *mode, int *open_flags) /* unknown mode */ return FAILURE; } -#if defined(O_NONBLOCK) - if (strchr(mode, 'n')) { - flags |= O_NONBLOCK; - } -#endif + if (strchr(mode, '+')) { flags |= O_RDWR; } else if (flags) { @@ -91,6 +87,12 @@ PHPAPI int php_stream_parse_fopen_modes(const char *mode, int *open_flags) flags |= O_RDONLY; } +#if defined(O_NONBLOCK) + if (strchr(mode, 'n')) { + flags |= O_NONBLOCK; + } +#endif + #if defined(_O_TEXT) && defined(O_BINARY) if (strchr(mode, 't')) { flags |= _O_TEXT; |