=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ftp/fetch.c,v retrieving revision 1.112 retrieving revision 1.113 diff -c -r1.112 -r1.113 *** src/usr.bin/ftp/fetch.c 2013/12/24 13:00:59 1.112 --- src/usr.bin/ftp/fetch.c 2014/02/26 20:48:06 1.113 *************** *** 1,4 **** ! /* $OpenBSD: fetch.c,v 1.112 2013/12/24 13:00:59 jca Exp $ */ /* $NetBSD: fetch.c,v 1.14 1997/08/18 10:20:20 lukem Exp $ */ /*- --- 1,4 ---- ! /* $OpenBSD: fetch.c,v 1.113 2014/02/26 20:48:06 tedu Exp $ */ /* $NetBSD: fetch.c,v 1.14 1997/08/18 10:20:20 lukem Exp $ */ /*- *************** *** 199,204 **** --- 199,205 ---- SSL *ssl = NULL; int status; int save_errno; + const size_t buflen = 128 * 1024; direction = "received"; *************** *** 418,430 **** hashbytes = mark; progressmeter(-1, path); ! if ((buf = malloc(4096)) == NULL) errx(1, "Can't allocate memory for transfer buffer"); /* Finally, suck down the file. */ i = 0; oldinti = signal(SIGINFO, psummary); ! while ((len = read(s, buf, 4096)) > 0) { bytes += len; for (cp = buf; len > 0; len -= i, cp += i) { if ((i = write(out, cp, len)) == -1) { --- 419,431 ---- hashbytes = mark; progressmeter(-1, path); ! if ((buf = malloc(buflen)) == NULL) errx(1, "Can't allocate memory for transfer buffer"); /* Finally, suck down the file. */ i = 0; oldinti = signal(SIGINFO, psummary); ! while ((len = read(s, buf, buflen)) > 0) { bytes += len; for (cp = buf; len > 0; len -= i, cp += i) { if ((i = write(out, cp, len)) == -1) { *************** *** 935,947 **** free(buf); /* Finally, suck down the file. */ ! if ((buf = malloc(4096)) == NULL) errx(1, "Can't allocate memory for transfer buffer"); i = 0; len = 1; oldinti = signal(SIGINFO, psummary); while (len > 0) { ! len = ftp_read(fin, ssl, buf, 4096); bytes += len; for (cp = buf, wlen = len; wlen > 0; wlen -= i, cp += i) { if ((i = write(out, cp, wlen)) == -1) { --- 936,948 ---- free(buf); /* Finally, suck down the file. */ ! if ((buf = malloc(buflen)) == NULL) errx(1, "Can't allocate memory for transfer buffer"); i = 0; len = 1; oldinti = signal(SIGINFO, psummary); while (len > 0) { ! len = ftp_read(fin, ssl, buf, buflen); bytes += len; for (cp = buf, wlen = len; wlen > 0; wlen -= i, cp += i) { if ((i = write(out, cp, wlen)) == -1) {