Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/progress Add missing check for error returns from re...



details:   https://anonhg.NetBSD.org/src/rev/ac62b975511a
branches:  trunk
changeset: 1022976:ac62b975511a
user:      gson <gson%NetBSD.org@localhost>
date:      Tue Aug 17 07:18:43 2021 +0000

description:
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.

diffstat:

 usr.bin/progress/progress.c |  10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diffs (31 lines):

diff -r f35503f57aba -r ac62b975511a usr.bin/progress/progress.c
--- a/usr.bin/progress/progress.c       Tue Aug 17 01:59:16 2021 +0000
+++ b/usr.bin/progress/progress.c       Tue Aug 17 07:18:43 2021 +0000
@@ -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 <sys/cdefs.h>
 #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 <sys/types.h>
@@ -231,7 +231,11 @@
                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,



Home | Main Index | Thread Index | Old Index