Return-Path: X-Original-To: apmail-httpd-cvs-archive@www.apache.org Delivered-To: apmail-httpd-cvs-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E9DB510E87 for ; Thu, 27 Feb 2014 18:09:00 +0000 (UTC) Received: (qmail 94695 invoked by uid 500); 27 Feb 2014 18:08:59 -0000 Delivered-To: apmail-httpd-cvs-archive@httpd.apache.org Received: (qmail 94644 invoked by uid 500); 27 Feb 2014 18:08:58 -0000 Mailing-List: contact cvs-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list cvs@httpd.apache.org Received: (qmail 94637 invoked by uid 99); 27 Feb 2014 18:08:58 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 27 Feb 2014 18:08:58 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 27 Feb 2014 18:08:56 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 58117238890D; Thu, 27 Feb 2014 18:08:35 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1572670 - /httpd/httpd/trunk/modules/filters/mod_deflate.c Date: Thu, 27 Feb 2014 18:08:35 -0000 To: cvs@httpd.apache.org From: ylavic@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140227180835.58117238890D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: ylavic Date: Thu Feb 27 18:08:34 2014 New Revision: 1572670 URL: http://svn.apache.org/r1572670 Log: Commit 5 on 6 to fix reentrance (incomplete Zlib header or validation bytes) in mod_deflate's output and input filters. PR 46146 (patches from duplicated PR 55666) Handle Zlib flags in the inflate input filter as in the output filter, using consume_zlib_flags(). Modified: httpd/httpd/trunk/modules/filters/mod_deflate.c Modified: httpd/httpd/trunk/modules/filters/mod_deflate.c URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/filters/mod_deflate.c?rev=1572670&r1=1572669&r2=1572670&view=diff ============================================================================== --- httpd/httpd/trunk/modules/filters/mod_deflate.c (original) +++ httpd/httpd/trunk/modules/filters/mod_deflate.c Thu Feb 27 18:08:34 2014 @@ -1087,10 +1087,10 @@ static apr_status_t deflate_in_filter(ap return APR_EGENERAL; } - /* We can't handle flags for now. */ - if (ctx->header[3] != 0) { + ctx->zlib_flags = ctx->header[3]; + if ((ctx->zlib_flags & RESERVED)) { ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, r, APLOGNO(01388) - "Zlib: Unsupported flags %02x", (int)ctx->header[3]); + "Zlib: Invalid flags %02x", ctx->zlib_flags); return APR_EGENERAL; } @@ -1188,6 +1188,16 @@ static apr_status_t deflate_in_filter(ap /* read */ apr_bucket_read(bkt, &data, &len, APR_BLOCK_READ); + if (ctx->zlib_flags) { + rv = consume_zlib_flags(ctx, &data, &len); + if (rv == APR_SUCCESS) { + ctx->zlib_flags = 0; + } + if (rv == APR_INCOMPLETE || !len) { + continue; + } + } + /* pass through zlib inflate. */ ctx->stream.next_in = (unsigned char *)data; ctx->stream.avail_in = len;