]> granicus.if.org Git - php/commitdiff
Widen allowable range of values for 'window' bits.
authorSara Golemon <pollita@php.net>
Tue, 22 Nov 2005 22:05:38 +0000 (22:05 +0000)
committerSara Golemon <pollita@php.net>
Tue, 22 Nov 2005 22:05:38 +0000 (22:05 +0000)
Make -MAX_WBITS default (to match gzinflate() and gzdeflate())

ext/zlib/zlib_filter.c

index c14437afb07194bdb0c016cef85ee814b203b07b..d0b3212b93d8460a5266c886d1a6013b421b9859 100644 (file)
@@ -303,7 +303,7 @@ static php_stream_filter *php_zlib_filter_create(const char *filtername, zval *f
        data->strm.data_type = Z_ASCII;
 
        if (strcasecmp(filtername, "zlib.inflate") == 0) {
-               int windowBits = MAX_WBITS;
+               int windowBits = -MAX_WBITS;
 
                if (filterparams) {
                        zval **tmpzval;
@@ -313,7 +313,7 @@ static php_stream_filter *php_zlib_filter_create(const char *filtername, zval *f
                                /* log-2 base of history window (9 - 15) */
                                SEPARATE_ZVAL(tmpzval);
                                convert_to_long_ex(tmpzval);
-                               if (Z_LVAL_PP(tmpzval) < 9 || Z_LVAL_PP(tmpzval) > MAX_WBITS) {
+                               if (Z_LVAL_PP(tmpzval) < -MAX_WBITS || Z_LVAL_PP(tmpzval) > MAX_WBITS) {
                                        php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter give for window size. (%ld)", Z_LVAL_PP(tmpzval));
                                } else {
                                        windowBits = Z_LVAL_PP(tmpzval);
@@ -328,7 +328,7 @@ static php_stream_filter *php_zlib_filter_create(const char *filtername, zval *f
        } else if (strcasecmp(filtername, "zlib.deflate") == 0) {
                /* RFC 1951 Deflate */
                int level = Z_DEFAULT_COMPRESSION;
-               int windowBits = MAX_WBITS;
+               int windowBits = -MAX_WBITS;
                int memLevel = MAX_MEM_LEVEL;
 
 
@@ -357,7 +357,7 @@ static php_stream_filter *php_zlib_filter_create(const char *filtername, zval *f
                                                /* log-2 base of history window (9 - 15) */
                                                SEPARATE_ZVAL(tmpzval);
                                                convert_to_long_ex(tmpzval);
-                                               if (Z_LVAL_PP(tmpzval) < 9 || Z_LVAL_PP(tmpzval) > MAX_WBITS) {
+                                               if (Z_LVAL_PP(tmpzval) < -MAX_WBITS || Z_LVAL_PP(tmpzval) > MAX_WBITS) {
                                                        php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter give for window size. (%ld)", Z_LVAL_PP(tmpzval));
                                                } else {
                                                        windowBits = Z_LVAL_PP(tmpzval);