From de6ec67a53799726d28fffc35f4dd319ffb87346 Mon Sep 17 00:00:00 2001 From: Yann Ylavic Date: Sat, 21 Jun 2014 21:13:45 +0000 Subject: [PATCH] Merge r1572092 from trunk: mod_deflate: fix decompression of files larger than 4GB. According to RFC1952, Input SIZE (compLen) contains the size of the original input data modulo 2^32. PR: 56062 Submitted by: Lukas Bezdicka Reviewed by: jkaluza, ylavic, covener git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1604460 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 3 +++ STATUS | 13 ------------- modules/filters/mod_deflate.c | 6 ++++-- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/CHANGES b/CHANGES index bbc00a51ce..2545574852 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,9 @@ Changes with Apache 2.4.10 + *) mod_deflate: Fix inflation of files larger than 4GB. PR 56062. + [Lukas Bezdicka ] + *) mod_deflate: Handle Zlib header and validation bytes received in multiple chunks. PR 46146. [Yann Ylavic] diff --git a/STATUS b/STATUS index ad3539eb15..24c9936607 100644 --- a/STATUS +++ b/STATUS @@ -100,19 +100,6 @@ RELEASE SHOWSTOPPERS: PATCHES ACCEPTED TO BACKPORT FROM TRUNK: [ start all new proposals below, under PATCHES PROPOSED. ] - * mod_deflate: Fix decompression of files larger than 4GB. According to RFC1952, - Input SIZE contains the size of the original input data modulo 2^32. - PR 56062. - Submitted by: [Lukas Bezdicka ] - Committed by: jkaluza - trunk patch: http://svn.apache.org/r1572092 - 2.4.x patch: http://people.apache.org/~ylavic/httpd-2.4.x-mod_deflate_4GB.patch - (modulo CHANGES, added lately from r1603156) - 2.4.x patch: trunk works - +1: ylavic, jkaluza, covener - ylavic: does not depend on r1572655 and al or r1572896 and al below, - these proposals can be backported in any order. - PATCHES PROPOSED TO BACKPORT FROM TRUNK: [ New proposals should be added at the end of the list ] diff --git a/modules/filters/mod_deflate.c b/modules/filters/mod_deflate.c index d3efad4b98..b8e8fd6e6e 100644 --- a/modules/filters/mod_deflate.c +++ b/modules/filters/mod_deflate.c @@ -1304,7 +1304,8 @@ static apr_status_t deflate_in_filter(ap_filter_t *f, return APR_EGENERAL; } compLen = getLong(buf + VALIDATION_SIZE / 2); - if (ctx->stream.total_out != compLen) { + /* gzip stores original size only as 4 byte value */ + if ((ctx->stream.total_out & 0xFFFFFFFF) != compLen) { inflateEnd(&ctx->stream); ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, r, APLOGNO(01395) "Zlib: Length %ld of inflated data does " @@ -1492,7 +1493,8 @@ static apr_status_t inflate_out_filter(ap_filter_t *f, } ctx->validation_buffer += VALIDATION_SIZE / 2; compLen = getLong(ctx->validation_buffer); - if (ctx->stream.total_out != compLen) { + /* gzip stores original size only as 4 byte value */ + if ((ctx->stream.total_out & 0xFFFFFFFF) != compLen) { ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01400) "Zlib: Length of inflated stream invalid"); return APR_EGENERAL; -- 2.40.0