summaryrefslogtreecommitdiffstats
path: root/libexec
diff options
context:
space:
mode:
authormaxim <maxim@FreeBSD.org>2002-02-13 09:00:05 +0000
committermaxim <maxim@FreeBSD.org>2002-02-13 09:00:05 +0000
commit8b9c5f26cd26f5f8cbbd0372fc83114d59f39509 (patch)
tree6f8f18f3d098371ad67ee983e5f5535177cd0944 /libexec
parent8b3deee04d3fc111d2eee20e927e1a1af906b729 (diff)
downloadFreeBSD-src-8b9c5f26cd26f5f8cbbd0372fc83114d59f39509.zip
FreeBSD-src-8b9c5f26cd26f5f8cbbd0372fc83114d59f39509.tar.gz
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
Diffstat (limited to 'libexec')
-rw-r--r--libexec/ftpd/ftpd.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/libexec/ftpd/ftpd.c b/libexec/ftpd/ftpd.c
index 60b1bf9..6c71150 100644
--- a/libexec/ftpd/ftpd.c
+++ b/libexec/ftpd/ftpd.c
@@ -1781,7 +1781,6 @@ send_data(FILE *instr, FILE *outstr, off_t blksize, off_t filesize, int isreg)
{
int c, filefd, netfd;
char *buf;
- size_t len;
off_t cnt;
transflag++;
@@ -1824,17 +1823,16 @@ send_data(FILE *instr, FILE *outstr, off_t blksize, off_t filesize, int isreg)
off_t offset;
int err;
- len = filesize;
err = cnt = offset = 0;
- while (err != -1 && cnt < filesize) {
- err = sendfile(filefd, netfd, offset, len,
+ while (err != -1 && filesize > 0) {
+ err = sendfile(filefd, netfd, offset, 0,
(struct sf_hdtr *) NULL, &cnt, 0);
if (recvurg)
goto got_oob;
byte_count += cnt;
offset += cnt;
- len -= cnt;
+ filesize -= cnt;
if (err == -1) {
if (!cnt)
OpenPOWER on IntegriCloud