Subject: bug#8154: du: issue with `--files0-from=DIR'

From: Stefan Vargyas <[email-masked]>
Date: Wed, 2 Mar 2011 05:28:14 -0800 (PST)

Dear maintainers,

While building and running coreutils v8.9, I came across the following issue of 'du':

  $ mkdir /tmp/foo
  $ du --files0-from=/tmp/foo
  du: `/tmp/foo': read error: Is a directory
  ...

The program enters an infinite loop -- continuously printing on stderr the error message shown above. Although such usage pattern of 'du' is erroneous, it better not behave this way. Looking into 'du.c', I found that the unending loop is caused by a misconceived 'continue' statement placed after a call to 'error' (the one labeled by 'case AI_ERR_READ'). A plausible fixing patch is immediate: see it enclosed.

Sincerely,

Stefan Vargyas.

--- coreutils-8.9/src/du.c	2011-01-01 23:19:23.000000000 +0200
+++ coreutils-8.9-stev/src/du.c	2011-03-02 03:32:04.000000000 +0200
@@ -926,8 +926,10 @@
           switch (ai_err)
             {
             case AI_ERR_READ:
-              error (0, errno, _("%s: read error"), quote (files_from));
-              continue;
+              error (EXIT_FAILURE, errno, _("%s: read error"),
+                     quote (files_from));
+              ok = false;
+              goto out_argv_iter;
 
             case AI_ERR_MEM:
               xalloc_die ();
@@ -978,6 +980,7 @@
           ok &= du_files (temp_argv, bit_flags);
         }
     }
+  out_argv_iter:
 
   argv_iter_free (ai);
   di_set_free (di_set);