summaryrefslogtreecommitdiff
path: root/buckets
diff options
context:
space:
mode:
authorGraham Leggett <minfrin@apache.org>2021-10-20 22:23:10 +0000
committerGraham Leggett <minfrin@apache.org>2021-10-20 22:23:10 +0000
commit2fb0412735d96a490f74bb89c702788a6964653b (patch)
tree12e7bf64e55f8bde2a13b996c71590b2ff72f304 /buckets
parentbf72faead62eb060a9de046164b2d7f6477a58f6 (diff)
downloadapr-2fb0412735d96a490f74bb89c702788a6964653b.tar.gz
apr_brigade_split_boundary: Rather than shaving one byte from
a bucket, ignore the byte instead on the next go-round. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1894423 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'buckets')
-rw-r--r--buckets/apr_brigade.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/buckets/apr_brigade.c b/buckets/apr_brigade.c
index ffe79765b..e8ec4ca3b 100644
--- a/buckets/apr_brigade.c
+++ b/buckets/apr_brigade.c
@@ -395,6 +395,7 @@ APR_DECLARE(apr_status_t) apr_brigade_split_boundary(apr_bucket_brigade *bbOut,
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_split_boundary(apr_bucket_brigade *bbOut,
* 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_split_boundary(apr_bucket_brigade *bbOut,
*/
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++;
}