diff --git a/changes-entries/deflate-xlen-unsigned.txt b/changes-entries/deflate-xlen-unsigned.txt new file mode 100644 index 00000000000..2633b824d23 --- /dev/null +++ b/changes-entries/deflate-xlen-unsigned.txt @@ -0,0 +1,4 @@ + *) mod_deflate: Read the gzip extra-field (FEXTRA) length as unsigned so a + length byte with the high bit set is no longer sign-extended, fixing + inflation of gzip streams that carry an extra field. + [arshiya tabasum ] diff --git a/modules/filters/mod_deflate.c b/modules/filters/mod_deflate.c index 5a541e73877..72b1e001ede 100644 --- a/modules/filters/mod_deflate.c +++ b/modules/filters/mod_deflate.c @@ -1053,7 +1053,7 @@ static apr_status_t consume_zlib_flags(deflate_ctx *ctx, if (!*len) { return APR_INCOMPLETE; } - ctx->consume_len = (unsigned int)**data; + ctx->consume_len = (unsigned int)(unsigned char)**data; ctx->consume_pos++; ++*data; --*len; @@ -1062,7 +1062,7 @@ static apr_status_t consume_zlib_flags(deflate_ctx *ctx, if (!*len) { return APR_INCOMPLETE; } - ctx->consume_len += ((unsigned int)**data) << 8; + ctx->consume_len += ((unsigned int)(unsigned char)**data) << 8; ctx->consume_pos++; ++*data; --*len;