diff options
author | Pádraig Brady <P@draigBrady.com> | 2023-04-23 23:45:08 +0100 |
---|---|---|
committer | Pádraig Brady <P@draigBrady.com> | 2023-04-24 11:46:28 +0100 |
commit | 82e1750daa3d002717234d8b37d21bdefbf826f4 (patch) | |
tree | e2c06d6ad4354cdbaee7fe9d6d88e9e3cf79ccfb | |
parent | 5595673d5cc2e3939edb898823dfb069296aa5b2 (diff) | |
download | coreutils-82e1750daa3d002717234d8b37d21bdefbf826f4.tar.gz |
factor: diagnose errors reading the input
* src/factor.c (do_stdin): Exit with failure upon read errors.
* NEWS: Mention the bug fix.
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | src/factor.c | 7 |
2 files changed, 7 insertions, 2 deletions
@@ -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); |