[PHP-CVS] cvs: php-src(PHP_5_3) /ext/zlib zlib.c /ext/zlib/tests 008.phpt

2009-05-28 Thread Arnaud Le Blanc
lbarnaudThu May 28 10:15:15 2009 UTC

  Added files: (Branch: PHP_5_3)
/php-src/ext/zlib/tests 008.phpt 

  Modified files:  
/php-src/ext/zlib   zlib.c 
  Log:
  MFB52: Fix "request_startup() for zlib module failed" when client does not
  accepts compression and zlib.output_compression is On
  # (not in HEAD)
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/zlib/zlib.c?r1=1.183.2.6.2.5.2.13&r2=1.183.2.6.2.5.2.14&diff_format=u
Index: php-src/ext/zlib/zlib.c
diff -u php-src/ext/zlib/zlib.c:1.183.2.6.2.5.2.13 
php-src/ext/zlib/zlib.c:1.183.2.6.2.5.2.14
--- php-src/ext/zlib/zlib.c:1.183.2.6.2.5.2.13  Tue May 26 08:03:07 2009
+++ php-src/ext/zlib/zlib.c Thu May 28 10:15:14 2009
@@ -19,7 +19,7 @@
+--+
  */
 
-/* $Id: zlib.c,v 1.183.2.6.2.5.2.13 2009/05/26 08:03:07 jani Exp $ */
+/* $Id: zlib.c,v 1.183.2.6.2.5.2.14 2009/05/28 10:15:14 lbarnaud Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -319,7 +319,9 @@
ZLIBG(ob_gzhandler_status) = 0;
ZLIBG(compression_coding) = 0;
 
-   return php_zlib_output_compression_start(TSRMLS_C);
+   php_zlib_output_compression_start(TSRMLS_C);
+
+   return SUCCESS;
 }
 /* }}} */
 

http://cvs.php.net/viewvc.cgi/php-src/ext/zlib/tests/008.phpt?view=markup&rev=1.1
Index: php-src/ext/zlib/tests/008.phpt
+++ php-src/ext/zlib/tests/008.phpt



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-CVS] cvs: php-src(PHP_5_3) /ext/zlib zlib.c

2009-05-26 Thread Jani Taskinen

Done.

--Jani

Hannes Magnusson wrote:

On Tue, May 26, 2009 at 07:54, Jani Taskinen  wrote:

janiTue May 26 05:54:50 2009 UTC

 Modified files:  (Branch: PHP_5_3)
   /php-src/ext/zlib   zlib.c
 Log:
 - Fixed bug #45202 (zlib.output_compression can not be set with ini_set())

http://cvs.php.net/viewvc.cgi/php-src/ext/zlib/zlib.c?r1=1.183.2.6.2.5.2.11&r2=1.183.2.6.2.5.2.12&diff_format=u
Index: php-src/ext/zlib/zlib.c
diff -u php-src/ext/zlib/zlib.c:1.183.2.6.2.5.2.11 
php-src/ext/zlib/zlib.c:1.183.2.6.2.5.2.12
--- php-src/ext/zlib/zlib.c:1.183.2.6.2.5.2.11  Tue May 26 04:44:54 2009
+++ php-src/ext/zlib/zlib.c Tue May 26 05:54:50 2009
+   switch (ZLIBG(output_compression)) {
+   case 0:
+   break;
+   case 1:
+   ZLIBG(output_compression) = 4096;
+   default:


If the missing 'break' is intentionally omitted, could you comment it as such?

-Hannes




--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_3) /ext/zlib zlib.c

2009-05-26 Thread Jani Taskinen
janiTue May 26 08:03:07 2009 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/zlib   zlib.c 
  Log:
  - Added note about omitted break
  
http://cvs.php.net/viewvc.cgi/php-src/ext/zlib/zlib.c?r1=1.183.2.6.2.5.2.12&r2=1.183.2.6.2.5.2.13&diff_format=u
Index: php-src/ext/zlib/zlib.c
diff -u php-src/ext/zlib/zlib.c:1.183.2.6.2.5.2.12 
php-src/ext/zlib/zlib.c:1.183.2.6.2.5.2.13
--- php-src/ext/zlib/zlib.c:1.183.2.6.2.5.2.12  Tue May 26 05:54:50 2009
+++ php-src/ext/zlib/zlib.c Tue May 26 08:03:07 2009
@@ -19,7 +19,7 @@
+--+
  */
 
-/* $Id: zlib.c,v 1.183.2.6.2.5.2.12 2009/05/26 05:54:50 jani Exp $ */
+/* $Id: zlib.c,v 1.183.2.6.2.5.2.13 2009/05/26 08:03:07 jani Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -1091,6 +1091,7 @@
break;
case 1:
ZLIBG(output_compression) = 4096;
+   /* break omitted intentionally */
default:
/* ZLIBG(compression_coding) should be 0 when zlib 
compression hasn't been started yet.. */
if (ZLIBG(compression_coding) == 0) {



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-CVS] cvs: php-src(PHP_5_3) /ext/zlib zlib.c

2009-05-26 Thread Hannes Magnusson
On Tue, May 26, 2009 at 07:54, Jani Taskinen  wrote:
> jani            Tue May 26 05:54:50 2009 UTC
>
>  Modified files:              (Branch: PHP_5_3)
>    /php-src/ext/zlib   zlib.c
>  Log:
>  - Fixed bug #45202 (zlib.output_compression can not be set with ini_set())
>
> http://cvs.php.net/viewvc.cgi/php-src/ext/zlib/zlib.c?r1=1.183.2.6.2.5.2.11&r2=1.183.2.6.2.5.2.12&diff_format=u
> Index: php-src/ext/zlib/zlib.c
> diff -u php-src/ext/zlib/zlib.c:1.183.2.6.2.5.2.11 
> php-src/ext/zlib/zlib.c:1.183.2.6.2.5.2.12
> --- php-src/ext/zlib/zlib.c:1.183.2.6.2.5.2.11  Tue May 26 04:44:54 2009
> +++ php-src/ext/zlib/zlib.c     Tue May 26 05:54:50 2009
> +       switch (ZLIBG(output_compression)) {
> +               case 0:
> +                       break;
> +               case 1:
> +                       ZLIBG(output_compression) = 4096;
> +               default:

If the missing 'break' is intentionally omitted, could you comment it as such?

-Hannes

--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_3) /ext/zlib zlib.c

2009-05-25 Thread Jani Taskinen
janiTue May 26 05:54:50 2009 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/zlib   zlib.c 
  Log:
  - Fixed bug #45202 (zlib.output_compression can not be set with ini_set())
  
http://cvs.php.net/viewvc.cgi/php-src/ext/zlib/zlib.c?r1=1.183.2.6.2.5.2.11&r2=1.183.2.6.2.5.2.12&diff_format=u
Index: php-src/ext/zlib/zlib.c
diff -u php-src/ext/zlib/zlib.c:1.183.2.6.2.5.2.11 
php-src/ext/zlib/zlib.c:1.183.2.6.2.5.2.12
--- php-src/ext/zlib/zlib.c:1.183.2.6.2.5.2.11  Tue May 26 04:44:54 2009
+++ php-src/ext/zlib/zlib.c Tue May 26 05:54:50 2009
@@ -19,7 +19,7 @@
+--+
  */
 
-/* $Id: zlib.c,v 1.183.2.6.2.5.2.11 2009/05/26 04:44:54 jani Exp $ */
+/* $Id: zlib.c,v 1.183.2.6.2.5.2.12 2009/05/26 05:54:50 jani Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -88,7 +88,7 @@
 /* True globals, no need for thread safety */
 static const int gz_magic[2] = {0x1f, 0x8b};   /* gzip magic header */
 
-static int php_enable_output_compression(int buffer_size TSRMLS_DC);
+static int php_zlib_output_compression_start(TSRMLS_D);
 
 static PHP_MINIT_FUNCTION(zlib);
 static PHP_MSHUTDOWN_FUNCTION(zlib);
@@ -228,6 +228,7 @@
 /* {{{ OnUpdate_zlib_output_compression */
 static PHP_INI_MH(OnUpdate_zlib_output_compression)
 {
+   int status, int_value;
char *ini_value;
 
if (new_value == NULL) {
@@ -242,8 +243,10 @@
new_value_length = sizeof("1");
}
 
+   int_value = zend_atoi(new_value, new_value_length);
ini_value = zend_ini_string("output_handler", sizeof("output_handler"), 
0);
-   if (ini_value != NULL && strlen(ini_value) != 0 && zend_atoi(new_value, 
new_value_length) != 0) {
+
+   if (ini_value && *ini_value && int_value) {
php_error_docref("ref.outcontrol" TSRMLS_CC, E_CORE_ERROR, 
"Cannot use both zlib.output_compression and output_handler together!!");
return FAILURE;
}
@@ -253,9 +256,13 @@
return FAILURE;
}
 
-   OnUpdateLong(entry, new_value, new_value_length, mh_arg1, mh_arg2, 
mh_arg3, stage TSRMLS_CC);
+   status = OnUpdateLong(entry, new_value, new_value_length, mh_arg1, 
mh_arg2, mh_arg3, stage TSRMLS_CC);
 
-   return SUCCESS;
+   if (stage == PHP_INI_STAGE_RUNTIME && int_value) {
+   status = php_zlib_output_compression_start(TSRMLS_C);
+   }
+
+   return status;
 }
 /* }}} */
 
@@ -309,18 +316,10 @@
  */
 static PHP_RINIT_FUNCTION(zlib)
 {
-   uint chunk_size = ZLIBG(output_compression);
-
ZLIBG(ob_gzhandler_status) = 0;
ZLIBG(compression_coding) = 0;
-   if (chunk_size) {
-   if (chunk_size == 1) {
-   chunk_size = 4096; /* use the default size */
-   ZLIBG(output_compression) = chunk_size;
-   }
-   php_enable_output_compression(chunk_size TSRMLS_CC);
-   }
-   return SUCCESS;
+
+   return php_zlib_output_compression_start(TSRMLS_C);
 }
 /* }}} */
 
@@ -1084,6 +1083,24 @@
 }
 /* }}} */
 
+/* {{{ php_zlib_output_compression_start() */
+static int php_zlib_output_compression_start(TSRMLS_D)
+{
+   switch (ZLIBG(output_compression)) {
+   case 0:
+   break;
+   case 1:
+   ZLIBG(output_compression) = 4096;
+   default:
+   /* ZLIBG(compression_coding) should be 0 when zlib 
compression hasn't been started yet.. */
+   if (ZLIBG(compression_coding) == 0) {
+   return 
php_enable_output_compression(ZLIBG(output_compression) TSRMLS_CC);
+   }
+   }
+   return SUCCESS;
+}
+/* }}} */
+
 /*
  * Local variables:
  * tab-width: 4



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_3) /ext/zlib zlib.c

2009-05-25 Thread Jani Taskinen
janiTue May 26 04:44:54 2009 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/zlib   zlib.c 
  Log:
  ws + cs
  http://cvs.php.net/viewvc.cgi/php-src/ext/zlib/zlib.c?r1=1.183.2.6.2.5.2.10&r2=1.183.2.6.2.5.2.11&diff_format=u
Index: php-src/ext/zlib/zlib.c
diff -u php-src/ext/zlib/zlib.c:1.183.2.6.2.5.2.10 
php-src/ext/zlib/zlib.c:1.183.2.6.2.5.2.11
--- php-src/ext/zlib/zlib.c:1.183.2.6.2.5.2.10  Tue Mar 24 01:57:53 2009
+++ php-src/ext/zlib/zlib.c Tue May 26 04:44:54 2009
@@ -19,7 +19,7 @@
+--+
  */
 
-/* $Id: zlib.c,v 1.183.2.6.2.5.2.10 2009/03/24 01:57:53 scottmac Exp $ */
+/* $Id: zlib.c,v 1.183.2.6.2.5.2.11 2009/05/26 04:44:54 jani Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -34,47 +34,51 @@
 #include 
 #include 
 #include 
+
 #ifdef PHP_WIN32
-#define O_RDONLY _O_RDONLY
-#include "win32/param.h"
+# define O_RDONLY _O_RDONLY
+# include "win32/param.h"
 #else
-#include 
+# include 
 /* #include  */
 #endif
+
 #include "ext/standard/head.h"
 #include "safe_mode.h"
 #include "ext/standard/php_standard.h"
 #include "ext/standard/info.h"
 #include "php_zlib.h"
 #include "fopen_wrappers.h"
+
 #if HAVE_PWD_H
-#ifdef PHP_WIN32
-#include "win32/pwd.h"
-#else
-#include 
-#endif
+# ifdef PHP_WIN32
+#  include "win32/pwd.h"
+# else
+#  include 
+# endif
 #endif
+
 #if defined(HAVE_UNISTD_H) && defined(PHP_WIN32)
-#undef HAVE_UNISTD_H
+# undef HAVE_UNISTD_H
 #endif
 
 #ifdef COMPILE_DL_ZLIB
-#ifndef PUTS
-#define PUTS(a) php_printf("%s",a)
-#endif
-#ifndef PUTC
-#define PUTC(a) PUTS(a)
-#endif
-#ifndef PHPWRITE
-#define PHPWRITE(a,n) php_write((a),(n) TSRMLS_CC)
-#endif
+# ifndef PUTS
+#  define PUTS(a) php_printf("%s",a)
+# endif
+# ifndef PUTC
+#  define PUTC(a) PUTS(a)
+# endif
+# ifndef PHPWRITE
+#  define PHPWRITE(a,n) php_write((a),(n) TSRMLS_CC)
+# endif
 #endif
 
 /* Win32 needs some more memory */
 #ifdef PHP_WIN32
-#define PHP_ZLIB_MODIFIER 100
+# define PHP_ZLIB_MODIFIER 100
 #else
-#define PHP_ZLIB_MODIFIER 1000
+# define PHP_ZLIB_MODIFIER 1000
 #endif
 
 #define OS_CODE0x03 /* FIXME */
@@ -171,10 +175,10 @@
PHP_FALIAS(gzwrite, fwrite, NULL)
PHP_FALIAS(gzputs,  fwrite, NULL)
PHP_FE(gzfile,  
arginfo_gzfile)
-   PHP_FE(gzcompress,  arginfo_gzcompress)
-   PHP_FE(gzuncompress,arginfo_gzuncompress)
-   PHP_FE(gzdeflate,   arginfo_gzdeflate)
-   PHP_FE(gzinflate,   arginfo_gzinflate)
+   PHP_FE(gzcompress,  
arginfo_gzcompress)
+   PHP_FE(gzuncompress,
arginfo_gzuncompress)
+   PHP_FE(gzdeflate,   
arginfo_gzdeflate)
+   PHP_FE(gzinflate,   
arginfo_gzinflate)
PHP_FE(gzencode,
arginfo_gzencode)
PHP_FE(ob_gzhandler,
arginfo_ob_gzhandler)
PHP_FE(zlib_get_coding_type,
arginfo_zlib_get_coding_type)
@@ -229,7 +233,7 @@
if (new_value == NULL) {
return FAILURE;
}
-   
+
if (!strncasecmp(new_value, "off", sizeof("off"))) {
new_value = "0";
new_value_length = sizeof("0");
@@ -238,7 +242,7 @@
new_value_length = sizeof("1");
}
 
-   ini_value = zend_ini_string("output_handler", sizeof("output_handler"), 
0); 
+   ini_value = zend_ini_string("output_handler", sizeof("output_handler"), 
0);
if (ini_value != NULL && strlen(ini_value) != 0 && zend_atoi(new_value, 
new_value_length) != 0) {
php_error_docref("ref.outcontrol" TSRMLS_CC, E_CORE_ERROR, 
"Cannot use both zlib.output_compression and output_handler together!!");
return FAILURE;
@@ -326,7 +330,7 @@
 {
php_unregister_url_stream_wrapper("zlib" TSRMLS_CC);
php_stream_filter_unregister_factory("zlib.*" TSRMLS_CC);
-   
+
UNREGISTER_INI_ENTRIES();
 
return SUCCESS;
@@ -383,7 +387,7 @@
while (php_stream_gets(stream, buf, sizeof(buf) - 1) != NULL) {
if (PG(magic_quotes_runtime)) {
int len;
-   
+
slashed = php_addslashes(buf, 0, &len, 0 TSRMLS_CC); /* 
0 = don't free source string */
add_index_stringl(return_value, i++, slashed, len, 0);
} else {
@@ -403,7 +407,7 @@
long flags = 0;
php_stream *stream;
int use_include_path = 0;
-   
+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|l", &filename, 
&filename_len, &mode

Re: [PHP-CVS] cvs: php-src(PHP_5_3) /ext/zlib zlib.c

2009-03-24 Thread Scott MacVicar
Hannes Magnusson wrote:
> 2009/3/24 Scott MacVicar :
>> scottmacTue Mar 24 01:57:54 2009 UTC
>>
>>  Modified files:  (Branch: PHP_5_3)
>>/php-src/ext/zlib   zlib.c
>>  Log:
>>  Fix bug #42362 - certain status codes never have output, so sending the 
>> gzip compression headers cause problems
>>
>>
>>
>> http://cvs.php.net/viewvc.cgi/php-src/ext/zlib/zlib.c?r1=1.183.2.6.2.5.2.9&r2=1.183.2.6.2.5.2.10&diff_format=u
>> Index: php-src/ext/zlib/zlib.c
>> diff -u php-src/ext/zlib/zlib.c:1.183.2.6.2.5.2.9 
>> php-src/ext/zlib/zlib.c:1.183.2.6.2.5.2.10
>> --- php-src/ext/zlib/zlib.c:1.183.2.6.2.5.2.9   Wed Dec 31 11:15:47 2008
>> +++ php-src/ext/zlib/zlib.c Tue Mar 24 01:57:53 2009
>> @@ -19,7 +19,7 @@
>>+--+
>>  */
>>
>> -/* $Id: zlib.c,v 1.183.2.6.2.5.2.9 2008/12/31 11:15:47 sebastian Exp $ */
>> +/* $Id: zlib.c,v 1.183.2.6.2.5.2.10 2009/03/24 01:57:53 scottmac Exp $ */
>>
>>  #ifdef HAVE_CONFIG_H
>>  #include "config.h"
>> @@ -1034,7 +1034,7 @@
>>  {
>>zend_bool do_start, do_end;
>>
>> -   if (!ZLIBG(output_compression)) {
>> +   if (!ZLIBG(output_compression) || 
>> SG(sapi_headers).http_response_code == 204 || 
>> SG(sapi_headers).http_response_code == 304) {
>>*handled_output = NULL;
> 
> What happens with:
>  header("HTTP/1.1 200 OK");
> exit;
> ?>
> or  header("Location: http://www.example.com/";);
> exit;
> ?>
>  ?
> 
> This looks more like treating the symptoms rather then fixing the problem..
> 
> -Hannes

204 and 304 can *never* have a body sent with them, its fine for all the
other status codes to have empty compessed output.

There is no simple fix for this because a flush() can occur with zero
output, this doesn't mean avoid gzipping. It's just nothing has been
sent to that point.

This is probably fixed in HEAD with the new output stuff though.

Scott

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-CVS] cvs: php-src(PHP_5_3) /ext/zlib zlib.c

2009-03-24 Thread Hannes Magnusson
2009/3/24 Scott MacVicar :
> scottmac                Tue Mar 24 01:57:54 2009 UTC
>
>  Modified files:              (Branch: PHP_5_3)
>    /php-src/ext/zlib   zlib.c
>  Log:
>  Fix bug #42362 - certain status codes never have output, so sending the gzip 
> compression headers cause problems
>
>
>
> http://cvs.php.net/viewvc.cgi/php-src/ext/zlib/zlib.c?r1=1.183.2.6.2.5.2.9&r2=1.183.2.6.2.5.2.10&diff_format=u
> Index: php-src/ext/zlib/zlib.c
> diff -u php-src/ext/zlib/zlib.c:1.183.2.6.2.5.2.9 
> php-src/ext/zlib/zlib.c:1.183.2.6.2.5.2.10
> --- php-src/ext/zlib/zlib.c:1.183.2.6.2.5.2.9   Wed Dec 31 11:15:47 2008
> +++ php-src/ext/zlib/zlib.c     Tue Mar 24 01:57:53 2009
> @@ -19,7 +19,7 @@
>    +--+
>  */
>
> -/* $Id: zlib.c,v 1.183.2.6.2.5.2.9 2008/12/31 11:15:47 sebastian Exp $ */
> +/* $Id: zlib.c,v 1.183.2.6.2.5.2.10 2009/03/24 01:57:53 scottmac Exp $ */
>
>  #ifdef HAVE_CONFIG_H
>  #include "config.h"
> @@ -1034,7 +1034,7 @@
>  {
>        zend_bool do_start, do_end;
>
> -       if (!ZLIBG(output_compression)) {
> +       if (!ZLIBG(output_compression) || SG(sapi_headers).http_response_code 
> == 204 || SG(sapi_headers).http_response_code == 304) {
>                *handled_output = NULL;

What happens with:

or http://www.example.com/";);
exit;
?>
 ?

This looks more like treating the symptoms rather then fixing the problem..

-Hannes

--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_3) /ext/zlib zlib.c

2009-03-23 Thread Scott MacVicar
scottmacTue Mar 24 01:57:54 2009 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/zlib   zlib.c 
  Log:
  Fix bug #42362 - certain status codes never have output, so sending the gzip 
compression headers cause problems
  
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/zlib/zlib.c?r1=1.183.2.6.2.5.2.9&r2=1.183.2.6.2.5.2.10&diff_format=u
Index: php-src/ext/zlib/zlib.c
diff -u php-src/ext/zlib/zlib.c:1.183.2.6.2.5.2.9 
php-src/ext/zlib/zlib.c:1.183.2.6.2.5.2.10
--- php-src/ext/zlib/zlib.c:1.183.2.6.2.5.2.9   Wed Dec 31 11:15:47 2008
+++ php-src/ext/zlib/zlib.c Tue Mar 24 01:57:53 2009
@@ -19,7 +19,7 @@
+--+
  */
 
-/* $Id: zlib.c,v 1.183.2.6.2.5.2.9 2008/12/31 11:15:47 sebastian Exp $ */
+/* $Id: zlib.c,v 1.183.2.6.2.5.2.10 2009/03/24 01:57:53 scottmac Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -1034,7 +1034,7 @@
 {
zend_bool do_start, do_end;
 
-   if (!ZLIBG(output_compression)) {
+   if (!ZLIBG(output_compression) || SG(sapi_headers).http_response_code 
== 204 || SG(sapi_headers).http_response_code == 304) {
*handled_output = NULL;
} else {
do_start = (mode & PHP_OUTPUT_HANDLER_START ? 1 : 0);



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_3) /ext/zlib zlib.c

2008-08-01 Thread Arnaud Le Blanc
lbarnaudSat Aug  2 02:36:25 2008 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/zlib   zlib.c 
  Log:
  MFH: Avoid leaks when zlib streams can not be closed properly.
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/zlib/zlib.c?r1=1.183.2.6.2.5.2.4&r2=1.183.2.6.2.5.2.5&diff_format=u
Index: php-src/ext/zlib/zlib.c
diff -u php-src/ext/zlib/zlib.c:1.183.2.6.2.5.2.4 
php-src/ext/zlib/zlib.c:1.183.2.6.2.5.2.5
--- php-src/ext/zlib/zlib.c:1.183.2.6.2.5.2.4   Thu Jul 24 14:38:37 2008
+++ php-src/ext/zlib/zlib.c Sat Aug  2 02:36:25 2008
@@ -19,7 +19,7 @@
+--+
  */
 
-/* $Id: zlib.c,v 1.183.2.6.2.5.2.4 2008/07/24 14:38:37 lbarnaud Exp $ */
+/* $Id: zlib.c,v 1.183.2.6.2.5.2.5 2008/08/02 02:36:25 lbarnaud Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -218,6 +218,19 @@
 ZEND_GET_MODULE(php_zlib)
 #endif
 
+/* {{{ Memory management wrappers */
+
+static voidpf php_zlib_alloc(voidpf opaque, uInt items, uInt size)
+{
+   return (voidpf)safe_emalloc(items, size, 0);
+}
+
+static void php_zlib_free(voidpf opaque, voidpf address)
+{
+   efree((void*)address);
+}
+/* }}} */
+
 /* {{{ OnUpdate_zlib_output_compression */
 static PHP_INI_MH(OnUpdate_zlib_output_compression)
 {
@@ -553,8 +566,8 @@
}
 
stream.data_type = Z_ASCII;
-   stream.zalloc = (alloc_func) Z_NULL;
-   stream.zfree  = (free_func) Z_NULL;
+   stream.zalloc = php_zlib_alloc;
+   stream.zfree  = php_zlib_free;
stream.opaque = (voidpf) Z_NULL;
 
stream.next_in = (Bytef *) data;
@@ -620,8 +633,8 @@
}
plength = limit;
 
-   stream.zalloc = (alloc_func) Z_NULL;
-   stream.zfree = (free_func) Z_NULL;
+   stream.zalloc = php_zlib_alloc;
+   stream.zfree = php_zlib_free;
stream.opaque = Z_NULL;
stream.avail_in = data_len + 1; /* there is room for \0 */
stream.next_in = (Bytef *) data;
@@ -746,8 +759,8 @@
int err;
 
if (do_start) {
-   ZLIBG(stream).zalloc = Z_NULL;
-   ZLIBG(stream).zfree = Z_NULL;
+   ZLIBG(stream).zalloc = php_zlib_alloc;
+   ZLIBG(stream).zfree = php_zlib_free;
ZLIBG(stream).opaque = Z_NULL;
 
switch (ZLIBG(compression_coding)) {
@@ -836,8 +849,8 @@
RETURN_FALSE;
}
 
-   stream.zalloc = Z_NULL;
-   stream.zfree = Z_NULL;
+   stream.zalloc = php_zlib_alloc;
+   stream.zfree = php_zlib_free;
stream.opaque = Z_NULL;
 
stream.next_in = (Bytef *) data;



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php