diff options
author | millert <millert@openbsd.org> | 2020-10-03 00:37:06 +0000 |
---|---|---|
committer | millert <millert@openbsd.org> | 2020-10-03 00:37:06 +0000 |
commit | d22d4275fb9ad5e94521c2a93b3ddf883ef09580 (patch) | |
tree | eccdf006f93a5455d704f34f156feb4dce913fe5 /bin | |
parent | Introduce `if_cloners_lock' rwlock and use it to serialize (diff) | |
download | wireguard-openbsd-d22d4275fb9ad5e94521c2a93b3ddf883ef09580.tar.xz wireguard-openbsd-d22d4275fb9ad5e94521c2a93b3ddf883ef09580.zip |
Use ferror() to check for write error, not the fflush() return value.
We can't rely on buffering to catch write errors in fflush().
Based on a diff from Demi M. Obenour, OK kn@
Diffstat (limited to 'bin')
-rw-r--r-- | bin/md5/md5.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/bin/md5/md5.c b/bin/md5/md5.c index dc6bf7eee6e..c58863c48e3 100644 --- a/bin/md5/md5.c +++ b/bin/md5/md5.c @@ -1,4 +1,4 @@ -/* $OpenBSD: md5.c,v 1.95 2019/05/18 16:53:39 otto Exp $ */ +/* $OpenBSD: md5.c,v 1.96 2020/10/03 00:37:06 millert Exp $ */ /* * Copyright (c) 2001,2003,2005-2007,2010,2013,2014 @@ -505,7 +505,8 @@ digest_file(const char *file, struct hash_list *hl, int echo) while ((nread = fread(data, 1UL, sizeof(data), fp)) != 0) { if (echo) { (void)fwrite(data, nread, 1UL, stdout); - if (fflush(stdout) != 0) + (void)fflush(stdout); + if (ferror(stdout)) err(1, "stdout: write error"); } TAILQ_FOREACH(hf, hl, tailq) |