mirror of
https://github.com/libevent/libevent.git
synced 2025-01-09 00:56:20 +08:00
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:
parent
7c2dea1615
commit
65abdc2011
4
buffer.c
4
buffer.c
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user