diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2019-04-11 14:25:40 +0200 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2019-04-11 16:52:36 +0200 |
commit | 2b28f7189144a21e753dbc09efadd571121a82b9 (patch) | |
tree | b40f387f5be293dde192f2743d14323160669128 /main/php_scandir.c | |
parent | 3e0f9c2c94d1511eaf30f8f1de8260f5821c985f (diff) | |
download | php-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/php_scandir.c')
-rw-r--r-- | main/php_scandir.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/main/php_scandir.c b/main/php_scandir.c index 94f5ef899d..7fdb49b77a 100644 --- a/main/php_scandir.c +++ b/main/php_scandir.c @@ -57,8 +57,7 @@ PHPAPI int php_scandir(const char *dirname, struct dirent **namelist[], int (*se struct dirent **vector = NULL; int vector_size = 0; int nfiles = 0; - char entry[sizeof(struct dirent)+MAXPATHLEN]; - struct dirent *dp = (struct dirent *)&entry; + struct dirent *dp; if (namelist == NULL) { return -1; @@ -68,7 +67,7 @@ PHPAPI int php_scandir(const char *dirname, struct dirent **namelist[], int (*se return -1; } - while (!php_readdir_r(dirp, (struct dirent *)entry, &dp) && dp) { + while ((dp = readdir(dirp))) { size_t dsize = 0; struct dirent *newdp = NULL; |