From 8522c6f09220abb95987976b7a9449f79d47944c Mon Sep 17 00:00:00 2001 From: Stas Bekman Date: Tue, 12 Aug 2003 17:46:29 +0000 Subject: [PATCH] Fix bug in mod_deflate, which was passing calling deflate() without checkinig first whether it has something to deflate. (currently this causes deflate to generate a fatal error according to the zlib spec). PR 22259. PR: Obtained from: Submitted by: Reviewed by: git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@100966 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 5 +++++ modules/filters/mod_deflate.c | 9 +++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGES b/CHANGES index d23ffce1c3..563a43f393 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,11 @@ Changes with Apache 2.1.0-dev [Remove entries to the current 2.0 section below, when backported] + *) Fix bug in mod_deflate, which was passing calling deflate() + without checkinig first whether it has something to deflate. (currently + this causes deflate to generate a fatal error according to the zlib spec). + PR 22259. [Stas Bekman] + *) Avoid an infinite recursion, which occured if the name of an included config file or directory contained a wildcard character. PR 22194. [André Malo] diff --git a/modules/filters/mod_deflate.c b/modules/filters/mod_deflate.c index 2744515aab..3730b5685b 100644 --- a/modules/filters/mod_deflate.c +++ b/modules/filters/mod_deflate.c @@ -530,10 +530,11 @@ static apr_status_t deflate_out_filter(ap_filter_t *f, if (APR_BUCKET_IS_FLUSH(e)) { apr_bucket *bkt; apr_status_t rv; - - zRC = deflate(&(ctx->stream), Z_SYNC_FLUSH); - if (zRC != Z_OK) { - return APR_EGENERAL; + if (ctx->stream.avail_in > 0) { + zRC = deflate(&(ctx->stream), Z_SYNC_FLUSH); + if (zRC != Z_OK) { + return APR_EGENERAL; + } } ctx->stream.next_out = ctx->buffer; -- 2.50.1