summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorScott Soule Cheloha <cheloha@cvs.openbsd.org>2023-03-04 00:00:26 +0000
committerScott Soule Cheloha <cheloha@cvs.openbsd.org>2023-03-04 00:00:26 +0000
commit0b22db2bec30f66f38d12d303c3cca6bf78d5fe9 (patch)
tree7a4eeade74323f93f7a9103fc4a627feb0453b49 /usr.bin
parent49f02b9cf8dba27c421a87a28ac7794263442269 (diff)
tee(1): explicitly check read(2) return value for 0 and -1
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/tee/tee.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/usr.bin/tee/tee.c b/usr.bin/tee/tee.c
index 0ead1771d19..e7e6fcf680f 100644
--- a/usr.bin/tee/tee.c
+++ b/usr.bin/tee/tee.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tee.c,v 1.14 2021/12/13 18:33:23 cheloha Exp $ */
+/* $OpenBSD: tee.c,v 1.15 2023/03/04 00:00:25 cheloha Exp $ */
/* $NetBSD: tee.c,v 1.5 1994/12/09 01:43:39 jtc Exp $ */
/*
@@ -114,7 +114,7 @@ main(int argc, char *argv[])
buf = malloc(BSIZE);
if (buf == NULL)
err(1, NULL);
- while ((rval = read(STDIN_FILENO, buf, BSIZE)) > 0) {
+ while ((rval = read(STDIN_FILENO, buf, BSIZE)) != 0 && rval != -1) {
SLIST_FOREACH(p, &head, next) {
for (n = 0; n < rval; n += wval) {
wval = write(p->fd, buf + n, rval - n);