[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 1/3] tsort: diagnose errors reading the input
From: |
Pádraig Brady |
Subject: |
[PATCH 1/3] tsort: diagnose errors reading the input |
Date: |
Sun, 23 Apr 2023 23:16:14 +0100 |
* src/tsort.c (tsort): Check for errors after readtoken().
* NEWS: Mention the bug fix.
---
NEWS | 3 +++
src/tsort.c | 6 +++++-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/NEWS b/NEWS
index a8db32246..2c68b1735 100644
--- 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]
diff --git a/src/tsort.c b/src/tsort.c
index 0032cb5d0..2775fb39e 100644
--- a/src/tsort.c
+++ b/src/tsort.c
@@ -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);
--
2.26.2
- [PATCH 1/3] tsort: diagnose errors reading the input,
Pádraig Brady <=