[cups.bugs] [HIGH] STR #1953: backend code ignores backends after hitting broken symbolic link

Ed Catmur ed at catmur.co.uk
Sun Sep 3 04:01:58 PDT 2006


[STR New]

The problem is in cupsDirRead:

  do
  {
    if (readdir_r(dp->dir, (struct dirent *)buffer, &entry))
    {
      DEBUG_printf(("    readdir_r() failed - %s\n", strerror(errno)));
      return (NULL);
    }

    if (!entry)
    {
      DEBUG_puts("    readdir_r() returned a NULL pointer!");
      return (NULL);
    }

    DEBUG_printf(("    readdir_r() returned \"%s\"...\n", entry->d_name));
  }
  while (!strcmp(entry->d_name, ".") || !strcmp(entry->d_name, ".."));

 /*
  * Copy the name over and get the file information...
  */

  strlcpy(dp->entry.filename, entry->d_name, sizeof(dp->entry.filename));

  snprintf(filename, sizeof(filename), "%s/%s", dp->directory,
entry->d_name);
  if (stat(filename, &(dp->entry.fileinfo)))
  {
    DEBUG_printf(("    stat() failed for \"%s\" - %s...\n", filename,
                  strerror(errno)));
    return (NULL);
  }

 /*
  * Return the entry...
  */

  return (&(dp->entry));
}

It returns NULL, indicating error reading directory or end of directory,
if the stat fails. It should instead just loop to the next dirent.

Link: http://www.cups.org/str.php?L1953
Version: 1.2.2





More information about the cups-devel mailing list