Avoid infinite loop if read() fails consistently.

PR:		misc/7926
Submitted by:	Sergey Potapov <sp@alkor.ru>
This commit is contained in:
Dag-Erling Smørgrav 1998-09-16 15:53:25 +00:00
parent 83e2676ff1
commit d26060f2e6
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=39363

View File

@ -103,7 +103,7 @@ crc32(fd, cval, clen)
len = 0 ;
crc32_total = ~crc32_total ;
while ((nr = read(fd, buf, sizeof(buf))))
while ((nr = read(fd, buf, sizeof(buf))) > 0)
for (len += nr, p = buf; nr--; ++p) {
CRC(crc, *p) ;
CRC(crc32_total, *p) ;