readdir_r(), otherwise it will segfault.
PR: #6479
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;
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 */
{
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;