Skip to content

Commit

Permalink
* buckets/apr_brigade.c (apr_brigade_split_line,
Browse files Browse the repository at this point in the history
  apr_brigade_to_iovec, apr_brigade_flatten): Ignore or cope
  with metadata buckets which return (NULL, 0) on read().

PR: 68278
Submitted by: Ben Kallus <benjamin.p.kallus.gr dartmouth.edu>, jorton
  • Loading branch information
notroj committed Dec 18, 2023
1 parent 66d3334 commit b0b1889
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions buckets/apr_brigade.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,9 @@ APR_DECLARE(apr_status_t) apr_brigade_flatten(apr_bucket_brigade *bb,
*
* No, we only copy the data up to their requested size. -- jre
*/
memcpy(c, str, str_len);
if (str_len) {
memcpy(c, str, str_len);
}

c += str_len;
actual += str_len;
Expand Down Expand Up @@ -353,13 +355,15 @@ APR_DECLARE(apr_status_t) apr_brigade_split_line(apr_bucket_brigade *bbOut,
return rv;
}

pos = memchr(str, APR_ASCII_LF, len);
/* We found a match. */
if (pos != NULL) {
apr_bucket_split(e, pos - str + 1);
APR_BUCKET_REMOVE(e);
APR_BRIGADE_INSERT_TAIL(bbOut, e);
return APR_SUCCESS;
if (len) {
pos = memchr(str, APR_ASCII_LF, len);
/* We found a match. */
if (pos != NULL) {
apr_bucket_split(e, pos - str + 1);
APR_BUCKET_REMOVE(e);
APR_BRIGADE_INSERT_TAIL(bbOut, e);
return APR_SUCCESS;
}
}
APR_BUCKET_REMOVE(e);
if (APR_BUCKET_IS_METADATA(e) || len > APR_BUCKET_BUFF_SIZE/4) {
Expand Down Expand Up @@ -700,6 +704,9 @@ APR_DECLARE(apr_status_t) apr_brigade_to_iovec(apr_bucket_brigade *b,
e != APR_BRIGADE_SENTINEL(b);
e = APR_BUCKET_NEXT(e))
{
/* Skip metadata buckets. */
if (APR_BUCKET_IS_METADATA(e)) continue;

if (left-- == 0)
break;

Expand Down

0 comments on commit b0b1889

Please sign in to comment.