Skip to content

Commit ae59c69

Browse files
committed
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
1 parent 3de6dd1 commit ae59c69

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ PHP NEWS
5050
. Soap::__setCookie() when cookie name is a digit is now not stored and represented
5151
as a string anymore but a int. (David Carlier)
5252

53+
- SPL:
54+
. DirectoryIterator key can now work better with filesystem supporting larger
55+
directory indexing. (David Carlier)
56+
5357
- Standard:
5458
. Fixed bug GH-19926 (reset internal pointer earlier while splicing array
5559
while COW violation flag is still set). (alexandre-daubois)

ext/spl/spl_directory.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ static zend_object *spl_filesystem_object_clone(zend_object *old_object)
414414
spl_filesystem_dir_open(intern, source->path);
415415
/* read until we hit the position in which we were before */
416416
bool skip_dots = SPL_HAS_FLAG(source->flags, SPL_FILE_DIR_SKIPDOTS);
417-
int index;
417+
zend_long index;
418418
for (index = 0; index < source->u.dir.index; ++index) {
419419
do {
420420
spl_filesystem_dir_read(intern);

ext/spl/spl_directory.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ struct _spl_filesystem_object {
6262
struct {
6363
php_stream *dirp;
6464
zend_string *sub_path;
65-
int index;
65+
zend_long index;
6666
zend_function *func_rewind;
6767
zend_function *func_next;
6868
zend_function *func_valid;

0 commit comments

Comments
 (0)