]> granicus.if.org Git - libevent/commitdiff
Fix critical bug in evbuffer_write when writev is not available
authorNick Mathewson <nickm@torproject.org>
Wed, 31 Mar 2010 16:29:26 +0000 (12:29 -0400)
committerNick Mathewson <nickm@torproject.org>
Wed, 31 Mar 2010 16:50:32 +0000 (12:50 -0400)
evbuffer_pullup() returns NULL if you try to pull up more bytes than
are there.  But evbuffer_write_atmost would sometimes ask for more
bytes to be pulled up than it had, get a NULL, and fail.

buffer.c

index 5cbd10b19f6d5ee2dd40bb02dffdaada3ee90c7f..3bec0c63c55a42a58dccb1f980a8ba77ca7cb5f0 100644 (file)
--- a/buffer.c
+++ b/buffer.c
@@ -1969,7 +1969,7 @@ evbuffer_write_atmost(struct evbuffer *buffer, evutil_socket_t fd,
                goto done;
        }
 
-       if (howmuch < 0)
+       if (howmuch < 0 || howmuch > buffer->total_len)
                howmuch = buffer->total_len;
 
        {