summaryrefslogtreecommitdiff
path: root/main/streams/plain_wrapper.c
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2019-04-11 14:25:40 +0200
committerNikita Popov <nikita.ppv@gmail.com>2019-04-11 16:52:36 +0200
commit2b28f7189144a21e753dbc09efadd571121a82b9 (patch)
treeb40f387f5be293dde192f2743d14323160669128 /main/streams/plain_wrapper.c
parent3e0f9c2c94d1511eaf30f8f1de8260f5821c985f (diff)
downloadphp-git-2b28f7189144a21e753dbc09efadd571121a82b9.tar.gz
Use readdir() instead of readdir_r()
readdir_r() is deprecated in modern glibc versions. readdir() is thread safe in practice, as long as there are no concurrent accesses on the *same* directory stream.
Diffstat (limited to 'main/streams/plain_wrapper.c')
-rw-r--r--main/streams/plain_wrapper.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/main/streams/plain_wrapper.c b/main/streams/plain_wrapper.c
index dc74bfccc1..1bfb2129dc 100644
--- a/main/streams/plain_wrapper.c
+++ b/main/streams/plain_wrapper.c
@@ -926,16 +926,15 @@ PHPAPI php_stream_ops php_stream_stdio_ops = {
static size_t php_plain_files_dirstream_read(php_stream *stream, char *buf, size_t count)
{
DIR *dir = (DIR*)stream->abstract;
- /* avoid libc5 readdir problems */
- char entry[sizeof(struct dirent)+MAXPATHLEN];
- struct dirent *result = (struct dirent *)&entry;
+ struct dirent *result;
php_stream_dirent *ent = (php_stream_dirent*)buf;
/* avoid problems if someone mis-uses the stream */
if (count != sizeof(php_stream_dirent))
return 0;
- if (php_readdir_r(dir, (struct dirent *)entry, &result) == 0 && result) {
+ result = readdir(dir);
+ if (result) {
PHP_STRLCPY(ent->d_name, result->d_name, sizeof(ent->d_name), strlen(result->d_name));
return sizeof(php_stream_dirent);
}