[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [Libevent-users] [PATCH] evbuffer_search_range fails when searching the last byte
- To: libevent-users@xxxxxxxxxxxxx
- Subject: Re: [Libevent-users] [PATCH] evbuffer_search_range fails when searching the last byte
- From: Nick Mathewson <nickm@xxxxxxxxxxxxx>
- Date: Mon, 6 Jun 2011 21:03:48 -0400
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: libevent-users-outgoing@xxxxxxxx
- Delivered-to: libevent-users@xxxxxxxx
- Delivery-date: Mon, 06 Jun 2011 21:03:56 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type; bh=vLtXjnToD1OBKDRnTfOrNFtl/O7jmQyw0gCbt6C1ZIs=; b=HwKC/6LhDr95AQ2VHL9hwHu6hu5VcqMwtoMJCnBbJ0pqHJQ2izSSYRVA3iUpvx1iZ7 1jdcDymu/hrbRvWpVd+S1DdDSuIbqAsQFztq63BsSHl+9Ubkg771bIPoKSNDaqrOFsTa PXxvnVLnojJN50OdZpCVvhaF5y3IHokSPqLtM=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type; b=jg8A3CrzPe3MCNxsAuWqmGjUL/Z+ACrsKyinJAJVnv6K7t0rEFHdoxpLoJszw9Oy2x lC29BvzQ0FyCmx3Bt0/y1j0m/QXjCCk4vhNRc1wb3L3mcocQ84z4apuTvy+jNt7b+dOQ 0Lzs47O3lmgk12tWQuYsIpmeOPFprVZPpyt6g=
- In-reply-to: <C8E9094E-016C-46A5-85C9-DDFC5C4111DD@xxxxxxxxx>
- References: <C8E9094E-016C-46A5-85C9-DDFC5C4111DD@xxxxxxxxx>
- Reply-to: libevent-users@xxxxxxxxxxxxx
- Sender: owner-libevent-users@xxxxxxxxxxxxx
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 byte
> with a non null end pointer.
>
> You can work around this by checking the buffer length and calling
> evbuffer_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.
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.
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?
yrs,
--
Nick
Attachment:
0002-Allow-evbuffer_ptr_set-to-yield-a-point-just-after-t.patch
Description: Binary data