Skip to content

Commit 5bee93f

Browse files
committed
Don't follow symlinks when cleaning out the temporary directory (Issue #1448)
1 parent a101405 commit 5bee93f

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

scheduler/file.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ cupsdCleanFiles(const char *path, /* I - Directory to clean */
3030
cups_dir_t *dir; /* Directory */
3131
cups_dentry_t *dent; /* Directory entry */
3232
char filename[1024]; /* Filename */
33+
struct stat fileinfo; /* File link information */
3334
int status; /* Status from unlink/rmdir */
3435

3536

@@ -48,15 +49,19 @@ cupsdCleanFiles(const char *path, /* I - Directory to clean */
4849
continue;
4950

5051
snprintf(filename, sizeof(filename), "%s/%s", path, dent->filename);
52+
if (lstat(filename, &fileinfo))
53+
continue;
5154

52-
if (S_ISDIR(dent->fileinfo.st_mode))
55+
if (S_ISDIR(fileinfo.st_mode))
5356
{
5457
cupsdCleanFiles(filename, pattern);
5558

5659
status = rmdir(filename);
5760
}
5861
else
62+
{
5963
status = cupsdUnlinkOrRemoveFile(filename);
64+
}
6065

6166
if (status)
6267
cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to remove \"%s\" - %s", filename,

0 commit comments

Comments
 (0)