From: Pádraig Brady
Date: Sun, 23 Apr 2023 22:45:08 +0000 (+0100) Subject: factor: diagnose errors reading the input X-Git-Tag: v9.4~155 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=82e1750daa3d002717234d8b37d21bdefbf826f4;p=thirdparty%2Fcoreutils.git factor: diagnose errors reading the input * src/factor.c (do_stdin): Exit with failure upon read errors. * NEWS: Mention the bug fix. --- diff --git a/NEWS b/NEWS index ec4920edc6..0590dd13a0 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 20508e355f..d37058bbec 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);