]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Don't serve symlinked or non-world-readable files (STR #4450)
authormsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Thu, 3 Jul 2014 14:37:16 +0000 (14:37 +0000)
committermsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Thu, 3 Jul 2014 14:37:16 +0000 (14:37 +0000)
git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@11993 a1ca3aef-8c08-0410-bb20-df032aa958be

scheduler/client.c

index edb3e9deb4b631f8700b42440e29bae6eb4fd1c0..73617eb709a562b34fd7d86e7ed4093d1796010a 100644 (file)
@@ -2961,7 +2961,7 @@ get_file(cupsd_client_t *con,             /* I  - Client connection */
     if ((ptr = strchr(filename, '?')) != NULL)
       *ptr = '\0';
 
-    if ((status = stat(filename, filestats)) != 0)
+    if ((status = lstat(filename, filestats)) != 0)
     {
      /*
       * Drop the language prefix and try the root directory...
@@ -2973,12 +2973,33 @@ get_file(cupsd_client_t *con,           /* I  - Client connection */
       if ((ptr = strchr(filename, '?')) != NULL)
        *ptr = '\0';
 
-      status = stat(filename, filestats);
+      status = lstat(filename, filestats);
     }
   }
 
  /*
-  * If we're found a directory, get the index.html file instead...
+  * If we've found a symlink, 404 the sucker to avoid disclosing information.
+  */
+
+  if (!status && S_ISLNK(filestats->st_mode))
+  {
+    cupsdLogClient(con, CUPSD_LOG_INFO, "Symlinks such as \"%s\" are not allowed.", filename);
+    return (NULL);
+  }
+
+ /*
+  * Similarly, if the file/directory does not have world read permissions, do
+  * not allow access...
+  */
+
+  if (!status && !(filestats->st_mode & S_IROTH))
+  {
+    cupsdLogClient(con, CUPSD_LOG_INFO, "Files/directories such as \"%s\" must be world-readable.", filename);
+    return (NULL);
+  }
+
+ /*
+  * If we've found a directory, get the index.html file instead...
   */
 
   if (!status && S_ISDIR(filestats->st_mode))