Commit: b5f5bff965c1a27a4820d0129d61f80ef8894e38 Author: Michael Wallner <m...@php.net> Fri, 6 Dec 2013 10:29:24 +0100 Parents: 098d2a5d0ff6353602654a9872c76c5811277546 Branches: PHP-5.4 PHP-5.5 PHP-5.6 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=b5f5bff965c1a27a4820d0129d61f80ef8894e38 Log: 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 Bugs: https://bugs.php.net/61645 Changed paths: M NEWS M main/streams/plain_wrapper.c Diff: diff --git a/NEWS b/NEWS index c0379f8..c601a8a 100644 --- a/NEWS +++ b/NEWS @@ -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 4ee8150..c188763 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; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php