On Jun 7, 2011, at 4:03 AM, Nick Mathewson wrote:
On Mon, Jun 6, 2011 at 8:37 PM, Nir Soffer <nirsof@xxxxxxxxx> wrote:Hi,I found that evbuffer_search_range fails when you try search the last bytewith a non null end pointer. You can work around this by checking the buffer length and callingevbuffer_search() instead, or evbuffer_search_range with a null end pointer.I don't know how to fix it yet, but I added a failing test case :-)That doesn't look like the problem's with evbuffer_search_range: Instead of setting 'end' to the last byte in the buffer, you're setting it to one *after* the last byte in the buffer, which makes evbuffer_set_ptr() return -1. If you get -1 from evbuffer_ptr_set(), you can't rely on the result.
True. The test should check this. See attached patch.
Arguably, evbuffer_ptr_set() should be able to represent not only every byte in the buffer, but also the point at the end of the buffer. But right now, it doesn't.
It will much useful like that :-)
Here's another patch that might make stuff work. Before I'd apply it, I'd like to have a look through everything that's using evbuffer_ptr_set() and evbuffer_ptr right now to make sure that nothing will freak out if it gets a pointer like this. What do you think?
Seem to work, but indeed need good review and probably more tests.
Attachment:
0002-Check-the-return-value-from-evbuffer_ptr_set.patch
Description: Binary data