Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 30 Oct 2002 06:43:14 +0100
From:      Dag-Erling Smorgrav <des@ofug.org>
To:        Bill Fenner <fenner@research.att.com>
Cc:        freebsd-current@freebsd.org
Subject:   Re: libfetch(3) patch for SSL
Message-ID:  <xzpela84h3h.fsf@flood.ping.uio.no>
In-Reply-To: <200210300312.g9U3CPZs021756@stash.attlabs.att.com> (Bill Fenner's message of "Tue, 29 Oct 2002 19:12:25 -0800 (PST)")
References:  <200210300312.g9U3CPZs021756@stash.attlabs.att.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Bill Fenner <fenner@research.att.com> writes:
> Turns out my writev patch for fetch broke SSL, since it could create
> iov[0].iov_len = 0, which would cause SSL_write(..,0), which would
> return 0, which would look like a short write and cause an error, which
> then gets ignored by http.c .  Ignoring the bigger picture of the error
> checking, this fix at least gets https: working again by making sure
> that _fetch_putln doesn't construct an iov with iov_len == 0.  (Yes,
> this is against rev 1.40, post-brouhaha).

I'd rather fix it like this:

Index: common.c
===================================================================
RCS file: /home/ncvs/src/lib/libfetch/common.c,v
retrieving revision 1.41
diff -u -r1.41 common.c
--- common.c    30 Oct 2002 04:43:00 -0000      1.41
+++ common.c    30 Oct 2002 05:37:17 -0000
@@ -470,7 +470,7 @@
 {
        struct timeval now, timeout, wait;
        fd_set writefds;
-       ssize_t wlen, total;
+       ssize_t want, wlen, total;
        int r;

        if (fetchTimeout) {
@@ -507,11 +507,11 @@
 #ifdef WITH_SSL
                if (conn->ssl != NULL)
                        wlen = SSL_write(conn->ssl,
-                           iov->iov_base, iov->iov_len);
+                           iov->iov_base, want = iov->iov_len);
                else
 #endif
-                       wlen = writev(conn->sd, iov, iovcnt);
-               if (wlen == 0) {
+                       wlen = writev(conn->sd, iov, want = iovcnt);
+               if (wlen == 0 && want != 0) {
                        /* we consider a short write a failure */
                        errno = EPIPE;
                        _fetch_syserr();

DES
-- 
Dag-Erling Smorgrav - des@ofug.org

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?xzpela84h3h.fsf>