]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Don't use readdir_r, ever.
authorMichael R Sweet <michaelrsweet@gmail.com>
Thu, 1 Jun 2017 19:50:41 +0000 (15:50 -0400)
committerMichael R Sweet <michaelrsweet@gmail.com>
Thu, 1 Jun 2017 19:50:41 +0000 (15:50 -0400)
cups/dir.c

index 65b8c4f9c3ee313f47604eddc938cb0cb8f897a1..b7cd400cbd268a2075ee87af19852198a476ba50 100644 (file)
@@ -3,7 +3,7 @@
  *
  * This set of APIs abstracts enumeration of directory entries.
  *
- * Copyright 2007-2012 by Apple Inc.
+ * Copyright 2007-2017 by Apple Inc.
  * Copyright 1997-2005 by Easy Software Products, all rights reserved.
  *
  * These coded instructions, statements, and computer programs are the
@@ -338,10 +338,6 @@ cupsDirRead(cups_dir_t *dp)                /* I - Directory pointer */
 {
   struct dirent        *entry;                 /* Pointer to entry */
   char         filename[1024];         /* Full filename */
-#  ifdef HAVE_PTHREAD_H
-  char         buffer[sizeof(struct dirent) + 1024];
-                                       /* Directory entry buffer */
-#  endif /* HAVE_PTHREAD_H */
 
 
   DEBUG_printf(("2cupsDirRead(dp=%p)", (void *)dp));
@@ -359,29 +355,8 @@ cupsDirRead(cups_dir_t *dp)                /* I - Directory pointer */
 
   for (;;)
   {
-#  ifdef HAVE_PTHREAD_H
    /*
-    * Read the next entry using the reentrant version of readdir...
-    */
-
-    if (readdir_r(dp->dir, (struct dirent *)buffer, &entry))
-    {
-      DEBUG_printf(("3cupsDirRead: readdir_r() failed - %s\n", strerror(errno)));
-      return (NULL);
-    }
-
-    if (!entry)
-    {
-      DEBUG_puts("3cupsDirRead: readdir_r() returned a NULL pointer!");
-      return (NULL);
-    }
-
-    DEBUG_printf(("4cupsDirRead: readdir_r() returned \"%s\"...",
-                  entry->d_name));
-
-#  else
-   /*
-    * Read the next entry using the original version of readdir...
+    * Read the next entry...
     */
 
     if ((entry = readdir(dp->dir)) == NULL)
@@ -392,8 +367,6 @@ cupsDirRead(cups_dir_t *dp)         /* I - Directory pointer */
 
     DEBUG_printf(("4cupsDirRead: readdir() returned \"%s\"...", entry->d_name));
 
-#  endif /* HAVE_PTHREAD_H */
-
    /*
     * Skip "." and ".."...
     */