httpd-apreq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Orton <jor...@redhat.com>
Subject Re: Endless loop in split_on_bdry() of library/parser_multipart.c?
Date Fri, 02 Jun 2006 12:57:48 GMT
[please CC me on replies]

On Tue, May 30, 2006 at 12:13:09PM +1000, Bojan Smojver wrote:
> I'm seeing an endless loop in this part of the code:
> 
> ------------------------------------------------
>             do {
>                 apr_bucket *f = APR_BRIGADE_FIRST(in);
>                 APR_BUCKET_REMOVE(f);
>                 APR_BRIGADE_INSERT_TAIL(out, f);
>             } while (e != APR_BRIGADE_FIRST(in));
> ------------------------------------------------

A loop like this will not terminate if "e" points to the brigade 
sentinel on entry; not sure if this is possible in the context of this 
code, but it's easy enough to verify with an assertion.

If all you want to do is move a section of buckets onto another brigade 
you can actually do it in a constant time operation, i.e. without having 
to iterate through all the buckets.  To splice buckets from "a" to "b" 
inclusively onto brigade "output", do:

   APR_RING_UNSPLICE(a, b, link);
   APR_RING_SPLICE_TAIL(&output->list, a, b, apr_bucket, link);

and APR_RING_SPLICE_HEAD can be used similarly.  It's a good idea to use 
the _CHECK_CONSISTENCY macros after using any APR_RING_* macros directly 
so that debug builds run the sanity checks.

Regards,

joe

Mime
View raw message