1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

ext/spl: DirectoryIterator to support modern filesytems.

With filesystems with builtin large capacity such as ZFS, Btfrs, NTFS
 or even ext4 with large_dir feature enabled, an int to represent an
entry index is falling short, thus risking overflows.

A zend_long however should cover this need without  increasing out
internal data structure.

close GH-20705
This commit is contained in:
David Carlier
2025-12-14 14:44:04 +00:00
parent 3de6dd12b6
commit ae59c69467
3 changed files with 6 additions and 2 deletions

4
NEWS
View File

@@ -50,6 +50,10 @@ PHP NEWS
. Soap::__setCookie() when cookie name is a digit is now not stored and represented
as a string anymore but a int. (David Carlier)
- SPL:
. DirectoryIterator key can now work better with filesystem supporting larger
directory indexing. (David Carlier)
- Standard:
. Fixed bug GH-19926 (reset internal pointer earlier while splicing array
while COW violation flag is still set). (alexandre-daubois)

View File

@@ -414,7 +414,7 @@ static zend_object *spl_filesystem_object_clone(zend_object *old_object)
spl_filesystem_dir_open(intern, source->path);
/* read until we hit the position in which we were before */
bool skip_dots = SPL_HAS_FLAG(source->flags, SPL_FILE_DIR_SKIPDOTS);
int index;
zend_long index;
for (index = 0; index < source->u.dir.index; ++index) {
do {
spl_filesystem_dir_read(intern);

View File

@@ -62,7 +62,7 @@ struct _spl_filesystem_object {
struct {
php_stream *dirp;
zend_string *sub_path;
int index;
zend_long index;
zend_function *func_rewind;
zend_function *func_next;
zend_function *func_valid;