Skip to content

Commit 38501ed

Browse files
joec4inielsdos
authored andcommitted
Fix GH-14930: Custom stream wrapper dir_readdir output truncated to 255 characters in PHP 8.3
Revert "Reserve less file space if possible in a directory entry" This reverts commit 00c1e7b. Closes GH-14933.
1 parent a23775a commit 38501ed

File tree

3 files changed

+31
-4
lines changed

3 files changed

+31
-4
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ PHP NEWS
5858
. Fix 32-bit wordwrap test failures. (orlitzky)
5959
. Fixed bug GH-14774 (time_sleep_until overflow). (David Carlier)
6060

61+
- Streams:
62+
. Fixed bug GH-14930 (Custom stream wrapper dir_readdir output truncated to
63+
255 characters in PHP 8.3). (Joe Cai)
64+
6165
- Tidy:
6266
. Fix memory leak in tidy_repair_file(). (nielsdos)
6367

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
--TEST--
2+
GH-14930: Custom stream wrapper dir_readdir output truncated to 255 characters in PHP 8.3
3+
--FILE--
4+
<?php
5+
6+
class DummyWrapper
7+
{
8+
public $context;
9+
10+
public function dir_opendir($url, $options)
11+
{
12+
return true;
13+
}
14+
15+
public function dir_readdir()
16+
{
17+
return 'very-long-filename-ieNoquiaC6ijeiy9beejaiphoriejo2cheehooGou8uhoh7eh0gefahyuQuohd7eec9auso9eeFah2Maedohsemi1eetoo5fo5biePh5eephai7SiuguipouLeemequ2oope9aigoQu5efak2aLeri9ithaiJ9eew3dianaiHoo1aexaighiitee6geghiequ5nohhiikahwee8ohk2Soip2Aikeithohdeitiedeiku7DiTh2eep3deitiedeiku7DiTh2ee.txt';
18+
}
19+
}
20+
21+
stream_wrapper_register('dummy', DummyWrapper::class);
22+
23+
$dh = opendir('dummy://', stream_context_create());
24+
var_dump(readdir($dh));
25+
?>
26+
--EXPECT--
27+
string(288) "very-long-filename-ieNoquiaC6ijeiy9beejaiphoriejo2cheehooGou8uhoh7eh0gefahyuQuohd7eec9auso9eeFah2Maedohsemi1eetoo5fo5biePh5eephai7SiuguipouLeemequ2oope9aigoQu5efak2aLeri9ithaiJ9eew3dianaiHoo1aexaighiitee6geghiequ5nohhiikahwee8ohk2Soip2Aikeithohdeitiedeiku7DiTh2eep3deitiedeiku7DiTh2ee.txt"

main/php_streams.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,7 @@ typedef struct _php_stream_statbuf {
107107
} php_stream_statbuf;
108108

109109
typedef struct _php_stream_dirent {
110-
#ifdef NAME_MAX
111-
char d_name[NAME_MAX + 1];
112-
#else
113110
char d_name[MAXPATHLEN];
114-
#endif
115111
unsigned char d_type;
116112
} php_stream_dirent;
117113

0 commit comments

Comments
 (0)