in ls.c, should check errno after readdir

Mike Coleman <[email protected]>
Newsgroups gmane.comp.gnu.fileutils.bugs
Message-ID <1029903894.29517.TMDA@debian>
In ls.c, errno should be checked after a NULL result from readdir, to see if
there was an error.  It may be that in a "normal" posix system, no error can
happen here, but my NAS box (an EMC Celerra) is reporting EACCES here, so a
defensive check, rather than ignoring the error, would be helpful.

I suppose this applies to all readdir's.

Regards,
Mike



  while ((next = readdir (reading)) != NULL)
    if (file_interesting (next))
      {
	enum filetype type = unknown;

#if HAVE_STRUCT_DIRENT_D_TYPE
	if (next->d_type == DT_DIR || next->d_type == DT_CHR
	    || next->d_type == DT_BLK || next->d_type == DT_SOCK
	    || next->d_type == DT_FIFO)
	  type = next->d_type;
#endif
	total_blocks += gobble_file (next->d_name, type, 0, name);
      }

  if (CLOSEDIR (reading))
    {
      error (0, errno, "%s", quotearg_colon (name));
      exit_status = 1;
      /* Don't return; print whatever we got. */
    }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.