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.
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;