]> granicus.if.org Git - php/commitdiff
MFH: Fixed bug #25218 ("deflate" compressed pages had a gzip header, which
authorStefan Roehrich <sr@php.net>
Thu, 28 Aug 2003 16:05:17 +0000 (16:05 +0000)
committerStefan Roehrich <sr@php.net>
Thu, 28 Aug 2003 16:05:17 +0000 (16:05 +0000)
should only be sent with "gzip" compressed pages).

NEWS
ext/zlib/zlib.c

diff --git a/NEWS b/NEWS
index 390155006da3fba1003088469d32193c990aef98..cb2a46a42062ea637916258fd88bfc315a0e5687 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,7 @@ PHP 4                                                                      NEWS
 - Fixed bug #25239 (ftp_fopen_wrapper not RFC compliant). (Sara)
 - Fixed bug #25166 (WDDX serializer handler missing in win32). (Jani)
 - Fixed bug #25109 (Possible crash when fetching field names in pgsql). (Ilia)
+- Fixed bug #25218 ("deflate" compressed pages had a gzip header). (Stefan)
 
 25 Aug 2003, Version 4.3.3
 - Upgraded the bundled Expat library to version 1.95.6. (Jani)
index 99bc86076b26a1439af8a8f73331553dcd5ebd45..21aa02876b282e7a09e09d03a93992111a84b82a 100644 (file)
@@ -687,7 +687,7 @@ static int php_do_deflate(uint str_length, Bytef **p_buffer, uint *p_buffer_len,
        Bytef *buffer;
        uInt prev_outlen, outlen;
        int err;
-       int start_offset = (do_start?10:0);
+       int start_offset = ((do_start && ZLIBG(compression_coding) == CODING_GZIP) ? 10 : 0);
        int end_offset = (do_end?8:0);
 
        outlen = (uint)(sizeof(char) * (str_length * 1.001f + 12) + 1); /* leave some room for a trailing \0 */
@@ -764,14 +764,14 @@ int php_deflate_string(const char *str, uint str_length, char **newstr, uint *ne
        ZLIBG(stream).next_in = (Bytef*) str;
        ZLIBG(stream).avail_in = (uInt) str_length;
 
-       if (ZLIBG(compression_coding) == 1) {
+       if (ZLIBG(compression_coding) == CODING_GZIP) {
                ZLIBG(crc) = crc32(ZLIBG(crc), (const Bytef *) str, str_length);
        }
 
        err = php_do_deflate(str_length, (Bytef **) newstr, new_length, do_start, do_end TSRMLS_CC);
        /* TODO: error handling (err may be Z_STREAM_ERROR, Z_BUF_ERROR, ?) */
 
-       if (do_start) {
+       if (do_start && ZLIBG(compression_coding) == CODING_GZIP) {
                /* Write a very simple .gz header: */
                (*newstr)[0] = gz_magic[0];
                (*newstr)[1] = gz_magic[1];
@@ -781,7 +781,7 @@ int php_deflate_string(const char *str, uint str_length, char **newstr, uint *ne
                *new_length += 10;
        }
        if (do_end) {
-               if (ZLIBG(compression_coding) == 1) {
+               if (ZLIBG(compression_coding) == CODING_GZIP) {
                        char *trailer = (*newstr)+(*new_length);
 
                        /* write crc & stream.total_in in LSB order */