From 3fb8bece12acd754e80bcd703dbc1e0930e6efef Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Thu, 30 Nov 2006 16:10:48 +0000 Subject: [PATCH] MFB: Thread-safety issues --- main/php_scandir.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main/php_scandir.c b/main/php_scandir.c index bad8d5eb70..27fc7d3ec9 100644 --- a/main/php_scandir.c +++ b/main/php_scandir.c @@ -62,6 +62,8 @@ int php_scandir(const char *dirname, struct dirent **namelist[], int (*selector) struct dirent *dp = NULL; int vector_size = 0; int nfiles = 0; + char entry[sizeof(struct dirent)+MAXPATHLEN]; + struct dirent *result = (struct dirent *)&entry; if (namelist == NULL) { return -1; @@ -71,7 +73,7 @@ int php_scandir(const char *dirname, struct dirent **namelist[], int (*selector) return -1; } - while ((dp = readdir(dirp)) != NULL) { + while ((dp = php_readdir_r(dirp, (struct dirent *)entry, &result)) == 0 && result) { int dsize = 0; struct dirent *newdp = NULL; -- 2.40.0