]> granicus.if.org Git - apache/commitdiff
mod_deflate: fix decompression of files larger than 4GB. According to RFC1952,
authorJan Kaluža <jkaluza@apache.org>
Wed, 26 Feb 2014 15:30:25 +0000 (15:30 +0000)
committerJan Kaluža <jkaluza@apache.org>
Wed, 26 Feb 2014 15:30:25 +0000 (15:30 +0000)
Input SIZE (compLen) contains the size of the original input data modulo 2^32.

PR: 56062
Submitted by: Lukas Bezdicka

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1572092 13f79535-47bb-0310-9956-ffa450edef68

modules/filters/mod_deflate.c

index 43ae858380da7b74d1c4daec13e5ff8f34e6b458..2166665f771be6584ea79d37eaeeef50c2ca7b15 100644 (file)
@@ -1125,7 +1125,8 @@ static apr_status_t deflate_in_filter(ap_filter_t *f,
                     }
                     ctx->stream.next_in += 4;
                     compLen = getLong(ctx->stream.next_in);
-                    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 "
@@ -1322,7 +1323,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;