when evbuffer_add_file is called and mmap is used, if the offset
argument is >0, a mistake happens: add_file removes "offset" byts
from the front of the evbuffer.
So that means any data that was previously on the buffer is trimmed
off by "offset" bytes. Whoops.
A onelinter fix: don't use evbuffer_drain for the offset, instead,
just modify the misalign variable on the newly created chain.
chain->buffer_len = length + offset;
chain->off = length + offset;
+ /* make way for pointing to the offset in the new chain if the
+ * offset was equested
+ */
+ chain->misalign = offset;
+
info = EVBUFFER_CHAIN_EXTRA(struct evbuffer_chain_fd, chain);
info->fd = fd;
outbuf->n_add_for_cb += length;
evbuffer_chain_insert(outbuf, chain);
-
- /* we need to subtract whatever we don't need */
- evbuffer_drain(outbuf, offset);
}
} else
#endif