Skip to content

Commit f5813db

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

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

CHANGES.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@ CHANGES - OpenPrinting CUPS
22
===========================
33

44

5+
Changes in CUPS v2.4.17 (YYYY-MM-DD)
6+
------------------------------------
7+
8+
- The scheduler followed symbolic links when cleaning out its temporary
9+
directory (Issue #1448)
10+
11+
512
Changes in CUPS v2.4.16 (2025-12-04)
613
------------------------------------
714

scheduler/file.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ cupsdCleanFiles(const char *path, /* I - Directory to clean */
3535
cups_dir_t *dir; /* Directory */
3636
cups_dentry_t *dent; /* Directory entry */
3737
char filename[1024]; /* Filename */
38+
struct stat fileinfo; /* File link information */
3839
int status; /* Status from unlink/rmdir */
3940

4041

@@ -57,15 +58,19 @@ cupsdCleanFiles(const char *path, /* I - Directory to clean */
5758
continue;
5859

5960
snprintf(filename, sizeof(filename), "%s/%s", path, dent->filename);
61+
if (lstat(filename, &fileinfo))
62+
continue;
6063

61-
if (S_ISDIR(dent->fileinfo.st_mode))
64+
if (S_ISDIR(fileinfo.st_mode))
6265
{
6366
cupsdCleanFiles(filename, pattern);
6467

6568
status = rmdir(filename);
6669
}
6770
else
71+
{
6872
status = cupsdUnlinkOrRemoveFile(filename);
73+
}
6974

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

0 commit comments

Comments
 (0)