File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -80,6 +80,7 @@ PHP NEWS
8080
8181- Posix:
8282 . Added validity check to the flags argument for posix_access(). (arshidkv12)
83+ . Added validity check to the permissions argument for posix_mkfifo(). (arshidkv12)
8384
8485- Reflection:
8586 . Fixed bug GH-20217 (ReflectionClass::isIterable() incorrectly returns true
Original file line number Diff line number Diff line change @@ -621,6 +621,11 @@ PHP_FUNCTION(posix_mkfifo)
621621 RETURN_FALSE ;
622622 }
623623
624+ if (mode < 0 || (mode & ~07777 )) {
625+ zend_argument_value_error (2 , "must be between 0 and 0o7777" );
626+ RETURN_THROWS ();
627+ }
628+
624629 result = mkfifo (ZSTR_VAL (path ), mode );
625630 if (result < 0 ) {
626631 POSIX_G (last_error ) = errno ;
Original file line number Diff line number Diff line change 1+ --TEST--
2+ posix_mkfifo(): invalid mode argument
3+ --SKIPIF--
4+ <?php
5+ if (!function_exists ("posix_mkfifo " )) {
6+ die ("skip no posix_mkfifo() " );
7+ }
8+ ?>
9+ --FILE--
10+ <?php
11+
12+ // Negative mode
13+ try {
14+ posix_mkfifo (__DIR__ . "/testfifo1 " , -1 );
15+ } catch (ValueError $ e ) {
16+ echo $ e ->getMessage (), "\n" ;
17+ }
18+
19+ // Too large mode
20+ try {
21+ posix_mkfifo (__DIR__ . "/testfifo2 " , 010000 ); // > 07777
22+ } catch (ValueError $ e ) {
23+ echo $ e ->getMessage (), "\n" ;
24+ }
25+
26+ // Garbage bits
27+ try {
28+ posix_mkfifo (__DIR__ . "/testfifo3 " , 020000 ); // S_IFCHR bit
29+ } catch (ValueError $ e ) {
30+ echo $ e ->getMessage (), "\n" ;
31+ }
32+ ?>
33+ --EXPECTF--
34+ posix_mkfifo(): Argument #2 ($permissions) must be between 0 and 0o7777
35+ posix_mkfifo(): Argument #2 ($permissions) must be between 0 and 0o7777
36+ posix_mkfifo(): Argument #2 ($permissions) must be between 0 and 0o7777
You can’t perform that action at this time.
0 commit comments