From: Sascha Schumann Date: Fri, 1 Sep 2000 09:38:19 +0000 (+0000) Subject: Solaris/x86 insists of having a large buffer for storing the result of X-Git-Tag: php-4.0.3RC1~384 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d60799bf6b5e79fc43054c07f6ba3cddbdaa1066;p=php Solaris/x86 insists of having a large buffer for storing the result of readdir_r(), otherwise it will segfault. PR: #6479 --- diff --git a/ext/session/mod_files.c b/ext/session/mod_files.c index 036cc7084e..fce7244b3d 100644 --- a/ext/session/mod_files.c +++ b/ext/session/mod_files.c @@ -151,7 +151,8 @@ static void _ps_files_open(ps_files *data, const char *key) static int _ps_files_cleanup_dir(const char *dirname, int maxlifetime) { DIR *dir; - struct dirent *entry, dentry; + char dentry[sizeof(struct dirent) + PATH_MAX + 1]; + struct dirent *entry; struct stat sbuf; char buf[MAXPATHLEN]; time_t now; @@ -165,7 +166,7 @@ static int _ps_files_cleanup_dir(const char *dirname, int maxlifetime) time(&now); - while (php_readdir_r(dir, &dentry, &entry) == 0 && entry) { + while (php_readdir_r(dir, (struct dirent *) dentry, &entry) == 0 && entry) { /* does the file start with our prefix? */ if (!strncmp(entry->d_name, FILE_PREFIX, sizeof(FILE_PREFIX) - 1) && /* create full path */ diff --git a/ext/standard/dir.c b/ext/standard/dir.c index 32674b696f..3ba53c67ab 100644 --- a/ext/standard/dir.c +++ b/ext/standard/dir.c @@ -289,13 +289,13 @@ PHP_FUNCTION(readdir) { pval **id, **tmp, *myself; php_dir *dirp; - struct dirent entry; + char entry[sizeof(struct dirent) + PATH_MAX + 1]; struct dirent *result; DIRLS_FETCH(); FETCH_DIRP(); - if (php_readdir_r(dirp->dir, &entry, &result) == 0 && result) { + if (php_readdir_r(dirp->dir, (struct dirent *) entry, &result) == 0 && result) { RETURN_STRINGL(result->d_name, strlen(result->d_name), 1); } RETURN_FALSE;