You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by "Spinka, Kristofer" <ks...@style.net> on 2002/09/11 05:38:11 UTC

[PATCH] mod_deflate 2.0.40 logic error

Description:
------------
  The Apache environment variable "gzip-only-text/html" was designed to
allow control over whether non-text/html content will be compressed with
the mod_deflate filter.  However, there is a small logic error in the
mod_deflate.c code that prevents this from functioning properly.


Resolution:
-----------
  There is an "if" statement that contains a call to the function strcmp,
which compares the value of the environment variable "gzip-only-text/html"
to the character string "1".  However, strcmp returns 0 on success, which
in this case will cause an undesired decision in this "if" statement.
  In addition, the ap_pass_brigade was "mispositioned", causing an
additional failure of this logic set; this is also corrected.


Patch:
------
--- orig/httpd-2.0.40/modules/filters/mod_deflate.c     Wed Aug  7
11:26:17 2002
+++ httpd-2.0.40/modules/filters/mod_deflate.c  Tue Sep 10 23:09:15 2002
@@ -281,10 +281,10 @@
              || strncmp(r->content_type, "text/html", 9)) {
             const char *env_value = apr_table_get(r->subprocess_env,
                                                   "gzip-only-text/html");
-            if ( env_value == NULL || strcmp(env_value,"1") ) {
+            if ( env_value == NULL || strncmp(env_value,"1",1) == 0 ) {
                 ap_remove_output_filter(f);
+                return ap_pass_brigade(f->next, bb);
             }
-            return ap_pass_brigade(f->next, bb);
         }

         /* Let's see what our current Content-Encoding is.
--- end patch

    /kris