From 0ca9fbc0deaf657b63e900f2a03ac2a315f07ee8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Loyet?= Date: Tue, 3 Jan 2012 22:26:11 +0000 Subject: [PATCH] - Fixed bug #60629 (memory corruption when web server closed the fcgi fd) --- NEWS | 4 ++++ sapi/fpm/fpm/fastcgi.c | 2 +- sapi/fpm/fpm/fastcgi.h | 2 +- sapi/fpm/fpm/fpm_main.c | 6 +++--- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index dac5b30042..ed32ed3caf 100644 --- a/NEWS +++ b/NEWS @@ -19,6 +19,10 @@ PHP NEWS . Fixed bug #48877 ("bindValue" and "bindParam" do not work for PDO Firebird). (Mariuz) +- PHP-FPM SAPI: + . Fixed bug #60629 (memory corruption when web server closed the fcgi fd). + (fat) + 08 Dec 2011, PHP 5.3.9RC3 diff --git a/sapi/fpm/fpm/fastcgi.c b/sapi/fpm/fpm/fastcgi.c index b8d10a538d..212b6ff1db 100644 --- a/sapi/fpm/fpm/fastcgi.c +++ b/sapi/fpm/fpm/fastcgi.c @@ -946,7 +946,7 @@ int fcgi_flush(fcgi_request *req, int close) return 1; } -int fcgi_write(fcgi_request *req, fcgi_request_type type, const char *str, int len) +ssize_t fcgi_write(fcgi_request *req, fcgi_request_type type, const char *str, int len) { int limit, rest; diff --git a/sapi/fpm/fpm/fastcgi.h b/sapi/fpm/fpm/fastcgi.h index caac528547..7a9f3ef363 100644 --- a/sapi/fpm/fpm/fastcgi.h +++ b/sapi/fpm/fpm/fastcgi.h @@ -127,7 +127,7 @@ char* fcgi_putenv(fcgi_request *req, char* var, int var_len, char* val); int fcgi_read(fcgi_request *req, char *str, int len); -int fcgi_write(fcgi_request *req, fcgi_request_type type, const char *str, int len); +ssize_t fcgi_write(fcgi_request *req, fcgi_request_type type, const char *str, int len); int fcgi_flush(fcgi_request *req, int close); void fcgi_set_mgmt_var(const char * name, size_t name_len, const char * value, size_t value_len); diff --git a/sapi/fpm/fpm/fpm_main.c b/sapi/fpm/fpm/fpm_main.c index 1d3488a1b8..ea0dd149f7 100644 --- a/sapi/fpm/fpm/fpm_main.c +++ b/sapi/fpm/fpm/fpm_main.c @@ -268,7 +268,7 @@ static void print_extensions(TSRMLS_D) static inline size_t sapi_cgibin_single_write(const char *str, uint str_length TSRMLS_DC) { - size_t ret; + ssize_t ret; /* sapi has started which means everyhting must be send through fcgi */ if (fpm_is_running) { @@ -277,7 +277,7 @@ static inline size_t sapi_cgibin_single_write(const char *str, uint str_length T if (ret <= 0) { return 0; } - return ret; + return (size_t)ret; } /* sapi has not started, output to stdout instead of fcgi */ @@ -286,7 +286,7 @@ static inline size_t sapi_cgibin_single_write(const char *str, uint str_length T if (ret <= 0) { return 0; } - return ret; + return (size_t)ret; #else return fwrite(str, 1, MIN(str_length, 16384), stdout); #endif -- 2.50.0