diff options
author | des <des@FreeBSD.org> | 1998-10-09 10:33:46 +0000 |
---|---|---|
committer | des <des@FreeBSD.org> | 1998-10-09 10:33:46 +0000 |
commit | 077f96877a5780ca47dc08850d8619b8272226b8 (patch) | |
tree | ee05db4a54e87d8ce461a777af885a88e3ef69bb /usr.bin/head | |
parent | 17e222060d5d55f16a21f1a940e17a88f01e2100 (diff) | |
download | FreeBSD-src-077f96877a5780ca47dc08850d8619b8272226b8.zip FreeBSD-src-077f96877a5780ca47dc08850d8619b8272226b8.tar.gz |
fread() returns 0 on eof or error, not EOF. This fixes the following
bug:
"head -c <n>" never exit and loops forever (until it is killed),
if the input stream has fewer bytes than specified (n).
PR: bin/8225
Submitted-by: FUJIMOTO Kensaku <fujimoto@oscar.elec.waseda.ac.jp>
Diffstat (limited to 'usr.bin/head')
-rw-r--r-- | usr.bin/head/head.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/usr.bin/head/head.c b/usr.bin/head/head.c index 6326605..fc4bdf6 100644 --- a/usr.bin/head/head.c +++ b/usr.bin/head/head.c @@ -42,7 +42,7 @@ static const char copyright[] = static char sccsid[] = "@(#)head.c 8.2 (Berkeley) 5/4/95"; #endif static const char rcsid[] = - "$Id: head.c,v 1.7 1997/07/10 06:46:13 charnier Exp $"; + "$Id: head.c,v 1.8 1997/07/11 06:13:18 charnier Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -157,7 +157,7 @@ head_bytes(fp, cnt) else readlen = sizeof(buf); readlen = fread(buf, sizeof(char), readlen, fp); - if (readlen == EOF) + if (readlen == 0) break; if (fwrite(buf, sizeof(char), readlen, stdout) != readlen) err(1, "stdout"); |