Skip to content

Commit 930ac9a

Browse files
author
Ilia Alshanetsky
committed
Thread-safety issues
1 parent 891bd78 commit 930ac9a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

main/php_scandir.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ int php_scandir(const char *dirname, struct dirent **namelist[], int (*selector)
6262
struct dirent *dp = NULL;
6363
int vector_size = 0;
6464
int nfiles = 0;
65+
char entry[sizeof(struct dirent)+MAXPATHLEN];
66+
struct dirent *result = (struct dirent *)&entry;
6567

6668
if (namelist == NULL) {
6769
return -1;
@@ -71,7 +73,7 @@ int php_scandir(const char *dirname, struct dirent **namelist[], int (*selector)
7173
return -1;
7274
}
7375

74-
while ((dp = readdir(dirp)) != NULL) {
76+
while ((dp = php_readdir_r(dirp, (struct dirent *)entry, &result)) == 0 && result) {
7577
int dsize = 0;
7678
struct dirent *newdp = NULL;
7779

0 commit comments

Comments
 (0)