Fix wrong sie calculation of iovec buffers when exact=1

The old code had a bug where the 'exact' flag to 1 in
_evbuffer_read_setup_vecs would never actually make the iov_len field
of the last iovec get truncated.  This patch fixes that.
This commit is contained in:
niks 2010-07-16 09:11:09 -04:00 committed by Nick Mathewson
parent 7c2dea1615
commit 65abdc2011

View File

@ -1844,8 +1844,8 @@ _evbuffer_read_setup_vecs(struct evbuffer *buf, ev_ssize_t howmuch,
chain = *firstchainp;
for (i = 0; i < n_vecs_avail && so_far < howmuch; ++i) {
size_t avail = CHAIN_SPACE_LEN(chain);
if (avail > howmuch && exact)
avail = howmuch;
if (avail > (howmuch - so_far) && exact)
avail = howmuch - so_far;
vecs[i].iov_base = CHAIN_SPACE_PTR(chain);
vecs[i].iov_len = avail;
so_far += avail;