-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #78862: link() silently truncates after a null byte on Windows
Since link() is supposed to accepts paths (i.e. strings without NUL bytes), we must not accept arbitrary strings.
- Loading branch information
Showing
2 changed files
with
18 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--TEST-- | ||
Bug #78862 (link() silently truncates after a null byte on Windows) | ||
--FILE-- | ||
<?php | ||
file_put_contents(__DIR__ . '/bug78862.target', 'foo'); | ||
var_dump(link(__DIR__ . "/bug78862.target\0more", __DIR__ . "/bug78862.link\0more")); | ||
var_dump(file_exists(__DIR__ . '/bug78862.link')); | ||
?> | ||
--EXPECTF-- | ||
Warning: link() expects parameter 1 to be a valid path, string given in %s on line %d | ||
NULL | ||
bool(false) | ||
--CLEAN-- | ||
<?php | ||
unlink(__DIR__ . '/bug78862.target'); | ||
unlink(__DIR__ . '/bug78862.link'); | ||
?> |