Skip to content

Commit 7b8d431

Browse files
committed
posix: validate mode argument in posix_mkfifo()
1 parent 1efc0fa commit 7b8d431

2 files changed

Lines changed: 30 additions & 7 deletions

File tree

ext/standard/tests/file/filetype_variation.phpt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,6 @@ posix_mkfifo( $file3, 0755);
4747
print( filetype( $file3) )."\n";
4848
unlink($file3);
4949

50-
try {
51-
posix_mkfifo('zz.txt', 10000 );
52-
} catch (\ValueError $e) {
53-
echo $e->getMessage() . PHP_EOL;
54-
}
55-
5650
/* Checking with block in file */
5751
/* To test this PEAR package should be installed */
5852

@@ -71,6 +65,5 @@ link
7165
dir
7266
-- Checking with fifo --
7367
fifo
74-
posix_mkfifo(): Argument #2 ($permissions) must be between 0 and 07777
7568

7669
*** Done ***
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
--TEST--
2+
posix_mkfifo(): invalid mode argument
3+
--FILE--
4+
<?php
5+
6+
// Negative mode
7+
try {
8+
posix_mkfifo(__DIR__ . "/testfifo1", -1);
9+
} catch (ValueError $e) {
10+
echo $e->getMessage(), "\n";
11+
}
12+
13+
// Too large mode
14+
try {
15+
posix_mkfifo(__DIR__ . "/testfifo2", 010000); // > 07777
16+
} catch (ValueError $e) {
17+
echo $e->getMessage(), "\n";
18+
}
19+
20+
// Garbage bits
21+
try {
22+
posix_mkfifo(__DIR__ . "/testfifo3", 020000); // S_IFCHR bit
23+
} catch (ValueError $e) {
24+
echo $e->getMessage(), "\n";
25+
}
26+
?>
27+
--EXPECTF--
28+
posix_mkfifo(): Argument #2 ($permissions) must be between 0 and 07777
29+
posix_mkfifo(): Argument #2 ($permissions) must be between 0 and 07777
30+
posix_mkfifo(): Argument #2 ($permissions) must be between 0 and 07777

0 commit comments

Comments
 (0)