mirror of
https://github.com/php/php-src.git
synced 2025-08-16 14:08:47 +02:00
preliminary fix for bug #73971, more refactoring is needed
This commit is contained in:
parent
8782e847b4
commit
609507024f
3 changed files with 57 additions and 3 deletions
54
ext/standard/tests/dir/dir_bug73971.phpt
Normal file
54
ext/standard/tests/dir/dir_bug73971.phpt
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
--TEST--
|
||||||
|
Bug #73971 Filename got limited to MAX_PATH on Win32 when scan directory
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (substr(PHP_OS, 0, 3) != 'WIN') {
|
||||||
|
die("skip Valid only on Windows");
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
$base = __DIR__ . DIRECTORY_SEPARATOR . "bug73971";
|
||||||
|
$filename = $base . DIRECTORY_SEPARATOR . str_repeat('テスト', 48); // 144 glyph here, less than 256
|
||||||
|
|
||||||
|
mkdir($base);
|
||||||
|
mkdir($filename); // created correctly
|
||||||
|
|
||||||
|
var_dump(basename($filename)); // 432 bytes here, more than 256
|
||||||
|
|
||||||
|
echo "\ntest dir()\n";
|
||||||
|
$d = dir($base);
|
||||||
|
while (false !== ($entry = $d->read())) {
|
||||||
|
var_dump($entry);
|
||||||
|
}
|
||||||
|
$d->close();
|
||||||
|
|
||||||
|
echo "\ntest DirectoryIterator\n";
|
||||||
|
$dir = new DirectoryIterator($base);
|
||||||
|
foreach ($dir as $finfo) {
|
||||||
|
var_dump($finfo->getFilename());
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
==DONE==
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
$base = __DIR__ . DIRECTORY_SEPARATOR . "bug73971";
|
||||||
|
$filename = $base . DIRECTORY_SEPARATOR . str_repeat('テスト', 48);
|
||||||
|
|
||||||
|
rmdir($filename);
|
||||||
|
rmdir($base);
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
string(432) "テストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテスト"
|
||||||
|
|
||||||
|
test dir()
|
||||||
|
string(1) "."
|
||||||
|
string(2) ".."
|
||||||
|
string(432) "テストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテスト"
|
||||||
|
|
||||||
|
test DirectoryIterator
|
||||||
|
string(1) "."
|
||||||
|
string(2) ".."
|
||||||
|
string(432) "テストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテストテスト"
|
||||||
|
==DONE==
|
|
@ -103,7 +103,7 @@ struct dirent *readdir(DIR *dp)
|
||||||
/* wide to utf8 failed, should never happen. */
|
/* wide to utf8 failed, should never happen. */
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
strlcpy(dp->dent.d_name, _tmp, _MAX_FNAME+1);
|
strlcpy(dp->dent.d_name, _tmp, _MAX_FNAME*4+1);
|
||||||
dp->dent.d_reclen = (unsigned short)strlen(dp->dent.d_name);
|
dp->dent.d_reclen = (unsigned short)strlen(dp->dent.d_name);
|
||||||
free(_tmp);
|
free(_tmp);
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ int readdir_r(DIR *dp, struct dirent *entry, struct dirent **result)
|
||||||
result = NULL;
|
result = NULL;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
strlcpy(dp->dent.d_name, _tmp, _MAX_FNAME+1);
|
strlcpy(dp->dent.d_name, _tmp, _MAX_FNAME*4+1);
|
||||||
dp->dent.d_reclen = (unsigned short)strlen(dp->dent.d_name);
|
dp->dent.d_reclen = (unsigned short)strlen(dp->dent.d_name);
|
||||||
free(_tmp);
|
free(_tmp);
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ struct dirent {
|
||||||
long d_ino; /* inode (always 1 in WIN32) */
|
long d_ino; /* inode (always 1 in WIN32) */
|
||||||
off_t d_off; /* offset to this dirent */
|
off_t d_off; /* offset to this dirent */
|
||||||
unsigned short d_reclen; /* length of d_name */
|
unsigned short d_reclen; /* length of d_name */
|
||||||
char d_name[PHP_WIN32_IOUTIL_MAXPATHLEN + 1]; /* filename (null terminated) */
|
char d_name[_MAX_FNAME*4+1]; /* filename with care about UTF-8 (null terminated) */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* typedef DIR - not the same as Unix */
|
/* typedef DIR - not the same as Unix */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue