From 82e1750daa3d002717234d8b37d21bdefbf826f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= Date: Sun, 23 Apr 2023 23:45:08 +0100 Subject: factor: diagnose errors reading the input * 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); -- cgit v1.2.1