coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 1/2] factor: diagnose errors reading the input


From: Pádraig Brady
Subject: [PATCH 1/2] factor: diagnose errors reading the input
Date: Sun, 23 Apr 2023 23:51:17 +0100

* src/factor.c (do_stdin): Exit with failure upon read errors.
* NEWS: Mention the bug fix.
---
 NEWS         | 2 +-
 src/factor.c | 7 ++++++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/NEWS b/NEWS
index ec4920edc..0590dd13a 100644
--- 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".]
 
 
diff --git a/src/factor.c b/src/factor.c
index 20508e355..d37058bbe 100644
--- a/src/factor.c
+++ b/src/factor.c
@@ -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);
-- 
2.26.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]