You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by mi...@apache.org on 2021/10/20 22:23:10 UTC
svn commit: r1894423 - /apr/apr/trunk/buckets/apr_brigade.c
Author: minfrin
Date: Wed Oct 20 22:23:10 2021
New Revision: 1894423
URL: http://svn.apache.org/viewvc?rev=1894423&view=rev
Log:
apr_brigade_split_boundary: Rather than shaving one byte from
a bucket, ignore the byte instead on the next go-round.
Modified:
apr/apr/trunk/buckets/apr_brigade.c
Modified: apr/apr/trunk/buckets/apr_brigade.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/buckets/apr_brigade.c?rev=1894423&r1=1894422&r2=1894423&view=diff
==============================================================================
--- apr/apr/trunk/buckets/apr_brigade.c (original)
+++ apr/apr/trunk/buckets/apr_brigade.c Wed Oct 20 22:23:10 2021
@@ -395,6 +395,7 @@ APR_DECLARE(apr_status_t) apr_brigade_sp
apr_off_t maxbytes)
{
apr_off_t outbytes = 0;
+ apr_off_t ignore = 0;
if (!boundary || !boundary[0]) {
return APR_EINVAL;
@@ -447,12 +448,12 @@ APR_DECLARE(apr_status_t) apr_brigade_sp
* If we have at least one boundary worth of data, do an optimised
* substring search for the boundary, and split quickly if found.
*/
- if (len >= boundary_len) {
+ if ((len - ignore) >= boundary_len) {
apr_size_t off;
apr_size_t leftover;
- pos = strnstr(str, boundary, len);
+ pos = strnstr(str + ignore, boundary, len - ignore);
/* definitely found it, we leave */
if (pos != NULL) {
@@ -518,7 +519,9 @@ APR_DECLARE(apr_status_t) apr_brigade_sp
*/
else {
- apr_size_t off = 0;
+ apr_size_t off = ignore;
+
+ len -= ignore;
/* find all definite non matches */
while (len) {
@@ -644,11 +647,7 @@ skip:
*
* Bump one byte off, and loop round to search again.
*/
- apr_bucket_split(e, 1);
- APR_BUCKET_REMOVE(e);
- APR_BRIGADE_INSERT_TAIL(bbOut, e);
-
- outbytes++;
+ ignore++;
}
Re: svn commit: r1894423 - /apr/apr/trunk/buckets/apr_brigade.c
Posted by Graham Leggett <mi...@sharp.fm>.
On 21 Oct 2021, at 12:57, Ruediger Pluem <rp...@apache.org> wrote:
>> *
>> * Bump one byte off, and loop round to search again.
>> */
>> - apr_bucket_split(e, 1);
>> - APR_BUCKET_REMOVE(e);
>> - APR_BRIGADE_INSERT_TAIL(bbOut, e);
>> -
>> - outbytes++;
>> + ignore++;
>
> Don't we need to reset ignore to 0 after each
>
> APR_BUCKET_REMOVE(e);
> APR_BRIGADE_INSERT_TAIL(bbOut, e);
>
> in the code above as we start with a new bucket then again and should use the what we read from it from the beginning?
Talked myself out of needing this, but we do yes.
Regards,
Graham
—
Re: svn commit: r1894423 - /apr/apr/trunk/buckets/apr_brigade.c
Posted by Ruediger Pluem <rp...@apache.org>.
On 10/21/21 12:23 AM, minfrin@apache.org wrote:
> Author: minfrin
> Date: Wed Oct 20 22:23:10 2021
> New Revision: 1894423
>
> URL: http://svn.apache.org/viewvc?rev=1894423&view=rev
> Log:
> apr_brigade_split_boundary: Rather than shaving one byte from
> a bucket, ignore the byte instead on the next go-round.
>
> Modified:
> apr/apr/trunk/buckets/apr_brigade.c
>
> Modified: apr/apr/trunk/buckets/apr_brigade.c
> URL: http://svn.apache.org/viewvc/apr/apr/trunk/buckets/apr_brigade.c?rev=1894423&r1=1894422&r2=1894423&view=diff
> ==============================================================================
> --- apr/apr/trunk/buckets/apr_brigade.c (original)
> +++ apr/apr/trunk/buckets/apr_brigade.c Wed Oct 20 22:23:10 2021
> @@ -644,11 +647,7 @@ skip:
> *
> * Bump one byte off, and loop round to search again.
> */
> - apr_bucket_split(e, 1);
> - APR_BUCKET_REMOVE(e);
> - APR_BRIGADE_INSERT_TAIL(bbOut, e);
> -
> - outbytes++;
> + ignore++;
Don't we need to reset ignore to 0 after each
APR_BUCKET_REMOVE(e);
APR_BRIGADE_INSERT_TAIL(bbOut, e);
in the code above as we start with a new bucket then again and should use the what we read from it from the beginning?
Regards
Rüdiger