summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjsing <jsing@openbsd.org>2015-09-10 13:43:35 +0000
committerjsing <jsing@openbsd.org>2015-09-10 13:43:35 +0000
commitc2920d8d4ed0f8db6727c509e3fc1f282bd7ba12 (patch)
tree0da2644d292871cea0838fc045727814b6654e76
parentOnly half of the IPv6 source address was used as input for the syn (diff)
downloadwireguard-openbsd-c2920d8d4ed0f8db6727c509e3fc1f282bd7ba12.tar.xz
wireguard-openbsd-c2920d8d4ed0f8db6727c509e3fc1f282bd7ba12.zip
Unbreak ftp(1) after tls_read()/tls_write() change.
Found the hard way by naddy@ Joint work with beck@
-rw-r--r--usr.bin/ftp/fetch.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/usr.bin/ftp/fetch.c b/usr.bin/ftp/fetch.c
index bcf8c76ea56..f7cfd99f019 100644
--- a/usr.bin/ftp/fetch.c
+++ b/usr.bin/ftp/fetch.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fetch.c,v 1.141 2015/09/10 10:35:58 beck Exp $ */
+/* $OpenBSD: fetch.c,v 1.142 2015/09/10 13:43:35 jsing Exp $ */
/* $NetBSD: fetch.c,v 1.14 1997/08/18 10:20:20 lukem Exp $ */
/*-
@@ -1459,17 +1459,17 @@ ftp_readline(FILE *fp, struct tls *tls, size_t *lenp)
size_t
ftp_read(FILE *fp, struct tls *tls, char *buf, size_t len)
{
- size_t ret;
+ ssize_t tls_ret;
+ size_t ret = 0;
+
if (fp != NULL)
ret = fread(buf, sizeof(char), len, fp);
#ifndef SMALL
- else if (tls!= NULL) {
- if ((ret = tls_read(tls, buf, len)) != 0)
- ret = 0;
+ else if (tls != NULL) {
+ if ((tls_ret = tls_read(tls, buf, len)) >= 0)
+ ret = (size_t)tls_ret;
}
#endif /* !SMALL */
- else
- ret = 0;
return (ret);
}
@@ -1547,7 +1547,7 @@ again:
ret = tls_read(tls, &c, 1);
if (ret == TLS_WANT_POLLIN || ret == TLS_WANT_POLLOUT)
goto again;
- if (ret != 0)
+ if (ret < 0)
errx(1, "SSL read error: %s", tls_error(tls));
buf[i] = c;