From e1d1003b4c257cc6fa7239b1b93d99fb1985449c Mon Sep 17 00:00:00 2001 From: gson Date: Tue, 17 Aug 2021 07:18:43 +0000 Subject: [PATCH] Add missing check for error returns from read(). Found by inspection while reviewing the changes suggested by RVP in PR install/56303, but not believed to be the cause of the failure reported in that PR. --- usr.bin/progress/progress.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/usr.bin/progress/progress.c b/usr.bin/progress/progress.c index 3f0b11f37bfb..87c7ab10dc80 100644 --- a/usr.bin/progress/progress.c +++ b/usr.bin/progress/progress.c @@ -1,4 +1,4 @@ -/* $NetBSD: progress.c,v 1.24 2021/08/09 10:46:39 gson Exp $ */ +/* $NetBSD: progress.c,v 1.25 2021/08/17 07:18:43 gson Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include #ifndef lint -__RCSID("$NetBSD: progress.c,v 1.24 2021/08/09 10:46:39 gson Exp $"); +__RCSID("$NetBSD: progress.c,v 1.25 2021/08/17 07:18:43 gson Exp $"); #endif /* not lint */ #include @@ -231,7 +231,11 @@ main(int argc, char *argv[]) do { nr = read(fd, fb_buf, buffersize); } while (nr < 0 && errno == EINTR); - if (nr <= 0) + if (nr < 0) { + progressmeter(1); + err(1, "reading input"); + } + if (nr == 0) break; for (off = 0; nr; nr -= nw, off += nw, bytes += nw) if ((nw = write(outpipe[1], fb_buf + off,