mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-11-15 23:05:49 +01:00
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>
This commit is contained in:
parent
1daa104c05
commit
710668cad4
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=40114
@ -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");
|
||||
|
Loading…
Reference in New Issue
Block a user