]> granicus.if.org Git - php/commitdiff
Solaris/x86 insists of having a large buffer for storing the result of
authorSascha Schumann <sas@php.net>
Fri, 1 Sep 2000 09:38:19 +0000 (09:38 +0000)
committerSascha Schumann <sas@php.net>
Fri, 1 Sep 2000 09:38:19 +0000 (09:38 +0000)
readdir_r(), otherwise it will segfault.

PR: #6479

ext/session/mod_files.c
ext/standard/dir.c

index 036cc7084ee148986c458b4114ed30453ba64dca..fce7244b3d063a4b944a31df5b8eee1dd58355bd 100644 (file)
@@ -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 */
index 32674b696feed4a6772dd0d4b1b8c9e1fae5a17f..3ba53c67ab912443ac335573219355b78d9b46c3 100644 (file)
@@ -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;