]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Don't follow symlinks when cleaning out the temporary directory (Issue #1448) master
authorMichael R Sweet <msweet@msweet.org>
Fri, 5 Dec 2025 15:28:44 +0000 (10:28 -0500)
committerMichael R Sweet <msweet@msweet.org>
Fri, 5 Dec 2025 15:29:25 +0000 (10:29 -0500)
scheduler/file.c

index 298533b7ea503e919761a499520a3425b86188d1..e909ed7cd1ac33da075551684969aff2a06c4360 100644 (file)
@@ -30,6 +30,7 @@ cupsdCleanFiles(const char *path,     /* I - Directory to clean */
   cups_dir_t   *dir;                   /* Directory */
   cups_dentry_t        *dent;                  /* Directory entry */
   char         filename[1024];         /* Filename */
+  struct stat  fileinfo;               /* File link information */
   int          status;                 /* Status from unlink/rmdir */
 
 
@@ -48,15 +49,19 @@ cupsdCleanFiles(const char *path,   /* I - Directory to clean */
       continue;
 
     snprintf(filename, sizeof(filename), "%s/%s", path, dent->filename);
+    if (lstat(filename, &fileinfo))
+      continue;
 
-    if (S_ISDIR(dent->fileinfo.st_mode))
+    if (S_ISDIR(fileinfo.st_mode))
     {
       cupsdCleanFiles(filename, pattern);
 
       status = rmdir(filename);
     }
     else
+    {
       status = cupsdUnlinkOrRemoveFile(filename);
+    }
 
     if (status)
       cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to remove \"%s\" - %s", filename,