Fix infinite loop around sendfile(2) after sending >4GB file.

PR:		bin/33770
Submitted by:	Vladislav Shabanov <vs@rambler-co.ru>
Reviewed by:	ru
Approved by:	ru
MFC after:	1 month
This commit is contained in:
maxim 2002-02-13 09:00:05 +00:00
parent f2225234bf
commit 506b5e2c1a

View File

@ -1781,7 +1781,6 @@ send_data(FILE *instr, FILE *outstr, off_t blksize, off_t filesize, int isreg)
{ {
int c, filefd, netfd; int c, filefd, netfd;
char *buf; char *buf;
size_t len;
off_t cnt; off_t cnt;
transflag++; transflag++;
@ -1824,17 +1823,16 @@ send_data(FILE *instr, FILE *outstr, off_t blksize, off_t filesize, int isreg)
off_t offset; off_t offset;
int err; int err;
len = filesize;
err = cnt = offset = 0; err = cnt = offset = 0;
while (err != -1 && cnt < filesize) { while (err != -1 && filesize > 0) {
err = sendfile(filefd, netfd, offset, len, err = sendfile(filefd, netfd, offset, 0,
(struct sf_hdtr *) NULL, &cnt, 0); (struct sf_hdtr *) NULL, &cnt, 0);
if (recvurg) if (recvurg)
goto got_oob; goto got_oob;
byte_count += cnt; byte_count += cnt;
offset += cnt; offset += cnt;
len -= cnt; filesize -= cnt;
if (err == -1) { if (err == -1) {
if (!cnt) if (!cnt)