]> granicus.if.org Git - libevent/commitdiff
Fix evbuffer_peek() with len==-1 and start_at non-NULL.
authorNick Mathewson <nickm@torproject.org>
Sun, 30 Nov 2014 16:05:40 +0000 (11:05 -0500)
committerNick Mathewson <nickm@torproject.org>
Sun, 30 Nov 2014 16:05:40 +0000 (11:05 -0500)
buffer.c

index f5a5210453481ab23daf4a6567f5762438e7e4d6..231f191456aee9cf83b153ef6b612925b1de0b3b 100644 (file)
--- a/buffer.c
+++ b/buffer.c
@@ -2742,7 +2742,10 @@ evbuffer_peek(struct evbuffer *buffer, ev_ssize_t len,
        if (n_vec == 0 && len < 0) {
                /* If no vectors are provided and they asked for "everything",
                 * pretend they asked for the actual available amount. */
-               len = buffer->total_len - len_so_far;
+               len = buffer->total_len;
+               if (start_at) {
+                       len -= start_at->pos;
+               }
        }
 
        while (chain) {