|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2012-01-10 19:58 UTC] dean at dacunha dot net
Description:
------------
unlink() function truncates the file path name argument in some cases.
This bug appears also with the rename() function in the same cases.
The given source code use link() to duplicate a file, then unlink() to remove the
source file. link() function works and unlink() bugs.
Test script:
---------------
#!/usr/local/bin/php
<?php
$Target="/mnt/M://BRASIL/Carlinhos Brown/Alfagamabetizado - Angel's Robot List.mp3";
$Link="/mnt/M:/NEWBASE/BRASIL/Carlinhos Brown/Alfagamabetizado - Angel's Robot List.1.2.mp3";
link($Target,$Link);
unlink($Target);
?>
Expected result:
----------------
unlink() should remove the "/mnt/M://BRASIL/Carlinhos Brown/Alfagamabetizado -
Angel's Robot List.mp3" file
Actual result:
--------------
root@djavanubu:/# ./b.php
Warning: unlink(BRASIL/Carlinhos Brown/Alfagamabetizado - Angel's Robot
List.mp3): No such file or directory in /b.php on line 8
###################
below trace shows the truncated file path given to unlink() syscall:
[...]
lstat("/mnt/M://BRASIL", {st_mode=S_IFDIR|0755, st_size=69632, ...}) = 0
link("/mnt/M://BRASIL/Carlinhos Brown/Alfagamabetizado - Angel's Robot
List.mp3", "/mnt/M:/NEWBASE/BRASIL/Carlinhos Brown/Alfagamabetizado - Angel's
Robot List.1.2.mp3") = 0
unlink("BRASIL/Carlinhos Brown/Alfagamabetizado - Angel's Robot List.mp3") = -1
ENOENT (No such file or directory)
write(1, "\nWarning: unlink(BRASIL/Carlinho"..., 130
Warning: unlink(BRASIL/Carlinhos Brown/Alfagamabetizado - Angel's Robot
List.mp3): No such file or directory in /b.php on line 8
) = 130
[...]
Patchesthemostevilpatchever2.patch (last revision 2012-02-12 09:53 UTC by shm@php.net)themostevilpatchever.patch (last revision 2012-02-11 08:32 UTC by shm@php.net) Pull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 15:00:01 2025 UTC |
Hi, I've just tested with php 5.3.10, the bug is still here. Do you still need me to test with version 5.3.9 ? Here is the proof: root@djavanubu:/root# root@djavanubu:/root# cat b.php #!/usr/local/bin/php <?php $Target="/mnt/M://BRASIL/Carlinhos Brown/Alfagamabetizado - Angel's Robot List.mp3"; $Link="/mnt/M:/NEWBASE/BRASIL/Carlinhos Brown/Alfagamabetizado - Angel's Robot List.1.2.mp3"; link($Target,$Link); unlink($Target); ?> root@djavanubu:/root# root@djavanubu:/root# /usr/local/bin/php -v PHP 5.3.10 (cli) (built: Jan 31 2012 22:48:16) Copyright (c) 1997-2012 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies root@djavanubu:/root# root@djavanubu:/root# root@djavanubu:/root# ./b.php Warning: unlink(BRASIL/Carlinhos Brown/Alfagamabetizado - Angel's Robot List.mp3): No such file or directory in /root/b.php on line 7 root@djavanubu:/root# root@djavanubu:/root# rm "/mnt/M:/NEWBASE/BRASIL/Carlinhos Brown/Alfagamabetizado - Angel's Robot List.1.2.mp3" root@djavanubu:/root# root@djavanubu:/root# strace ./b.php [...] lstat("/mnt/M://BRASIL/Carlinhos Brown/Alfagamabetizado - Angel's Robot List.mp3", {st_mode=S_IFREG|0755, st_size=1247232, ...}) = 0 lstat("/mnt/M://BRASIL/Carlinhos Brown", {st_mode=S_IFDIR|0755, st_size=40960, ...}) = 0 lstat("/mnt/M://BRASIL", {st_mode=S_IFDIR|0755, st_size=81920, ...}) = 0 link("/mnt/M://BRASIL/Carlinhos Brown/Alfagamabetizado - Angel's Robot List.mp3", "/mnt/M:/NEWBASE/BRASIL/Carlinhos Brown/Alfagamabetizado - Angel's Robot List.1.2.mp3") = 0 unlink("BRASIL/Carlinhos Brown/Alfagamabetizado - Angel's Robot List.mp3") = -1 ENOENT (No such file or directory) write(1, "\nWarning: unlink(BRASIL/Carlinho"..., 135 Warning: unlink(BRASIL/Carlinhos Brown/Alfagamabetizado - Angel's Robot List.mp3): No such file or directory in /root/b.php on line 7 ) = 135 [...]