diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2015-07-18 21:50:48 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2015-07-18 21:50:48 +0000 |
commit | c1156af9b7a5e0f1eab1cd49b29446913cc33a19 (patch) | |
tree | 6edca0dd1763cd8ea0e2005b53298d958106bde1 /usr.bin/ftp | |
parent | 16f341da31a7b7362018cc9d409859fa69c42ce5 (diff) |
Handle short writes and TLS_{READ,WRITE}_AGAIN around tls_write().
input doug@; OK beck@
Diffstat (limited to 'usr.bin/ftp')
-rw-r--r-- | usr.bin/ftp/fetch.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/usr.bin/ftp/fetch.c b/usr.bin/ftp/fetch.c index 9e2fbd27b07..ce1a88ff6fd 100644 --- a/usr.bin/ftp/fetch.c +++ b/usr.bin/ftp/fetch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fetch.c,v 1.138 2015/02/27 17:38:19 jca Exp $ */ +/* $OpenBSD: fetch.c,v 1.139 2015/07/18 21:50:47 bluhm Exp $ */ /* $NetBSD: fetch.c,v 1.14 1997/08/18 10:20:20 lukem Exp $ */ /*- @@ -1509,13 +1509,23 @@ ftp_printf(FILE *fp, struct tls *tls, const char *fmt, ...) int SSL_vprintf(struct tls *tls, const char *fmt, va_list ap) { - char *string; - size_t nw; + char *string, *buf; + size_t nw, len; int ret; if ((ret = vasprintf(&string, fmt, ap)) == -1) return ret; - ret = tls_write(tls, string, ret, &nw); + buf = string; + len = ret; + while (len > 0) { + ret = tls_write(tls, buf, len, &nw); + if (ret == TLS_READ_AGAIN || ret == TLS_WRITE_AGAIN) + continue; + if (ret < 0) + break; + buf += nw; + len -= nw; + } free(string); return ret; } |