]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tsort: diagnose errors reading the input
authorPádraig Brady <P@draigBrady.com>
Sat, 22 Apr 2023 20:41:53 +0000 (21:41 +0100)
committerPádraig Brady <P@draigBrady.com>
Mon, 24 Apr 2023 10:46:28 +0000 (11:46 +0100)
* src/tsort.c (tsort): Check for errors after readtoken().
* NEWS: Mention the bug fix.

NEWS
src/tsort.c

diff --git a/NEWS b/NEWS
index a8db32246b64793dee1c78cc6bdf242fef3ededa..2c68b1735f26987632cff9c14c369f161f24b8a3 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,9 @@ GNU coreutils NEWS                                    -*- outline -*-
   Previously such file names would have caused the strip process to fail.
   [This bug was present in "the beginning".]
 
+  tsort now diagnoses read errors on the input.
+  [This bug was present in "the beginning".]
+
 
 * Noteworthy changes in release 9.3 (2023-04-18) [stable]
 
index 0032cb5d0b6bc7f7f7e4fb2b30a40c50a87d6327..2775fb39eb63355a49432a9fe598ef623c21e572 100644 (file)
@@ -453,7 +453,11 @@ tsort (char const *file)
       /* T2. Next Relation.  */
       size_t len = readtoken (stdin, DELIM, sizeof (DELIM) - 1, &tokenbuffer);
       if (len == (size_t) -1)
-        break;
+        {
+          if (ferror (stdin))
+            die (EXIT_FAILURE, errno, _("%s: read error"), quotef (file));
+          break;
+        }
 
       assert (len != 0);