]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
factor: diagnose errors reading the input
authorPádraig Brady <P@draigBrady.com>
Sun, 23 Apr 2023 22:45:08 +0000 (23:45 +0100)
committerPádraig Brady <P@draigBrady.com>
Mon, 24 Apr 2023 10:46:28 +0000 (11:46 +0100)
* src/factor.c (do_stdin): Exit with failure upon read errors.
* NEWS: Mention the bug fix.

NEWS
src/factor.c

diff --git a/NEWS b/NEWS
index ec4920edc6463c9eb86574d3c685ec7c72cb3ed9..0590dd13a02c7384e572565d82bccbf3b3214c2a 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -11,7 +11,7 @@ GNU coreutils NEWS                                    -*- outline -*-
   Previously such file names would have caused the strip process to fail.
   [This bug was present in "the beginning".]
 
-  tsort and numfmt now diagnose read errors on the input.
+  factor, numfmt, and tsort now diagnose read errors on the input.
   [This bug was present in "the beginning".]
 
 
index 20508e355ffb8a806fd7a88f76339f9c30175413..d37058bbecc83d8a003ed3932fbf650c263b582d 100644 (file)
@@ -2588,7 +2588,12 @@ do_stdin (void)
       size_t token_length = readtoken (stdin, DELIM, sizeof (DELIM) - 1,
                                        &tokenbuffer);
       if (token_length == (size_t) -1)
-        break;
+        {
+          if (ferror (stdin))
+            die (EXIT_FAILURE, errno, _("error reading input"));
+          break;
+        }
+
       ok &= print_factors (tokenbuffer.buffer);
     }
   free (tokenbuffer.buffer);