tony2001 Thu Apr 13 11:26:43 2006 UTC
Modified files:
/php-src/ext/curl interface.c multi.c
Log:
MF51:
fix bug #37061 (curl_exec() doesn't zero-terminate binary strings) - we get
the data length from cURL, so it's binary safe.
fix leak appearing when re-using curl handle
http://cvs.php.net/viewcvs.cgi/php-src/ext/curl/interface.c?r1=1.78&r2=1.79&diff_format=u
Index: php-src/ext/curl/interface.c
diff -u php-src/ext/curl/interface.c:1.78 php-src/ext/curl/interface.c:1.79
--- php-src/ext/curl/interface.c:1.78 Tue Apr 11 11:32:06 2006
+++ php-src/ext/curl/interface.c Thu Apr 13 11:26:43 2006
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: interface.c,v 1.78 2006/04/11 11:32:06 sniper Exp $ */
+/* $Id: interface.c,v 1.79 2006/04/13 11:26:43 tony2001 Exp $ */
#define ZEND_INCLUDE_FULL_WINDOWS_HEADERS
@@ -1206,6 +1206,8 @@
if (Z_LVAL_PP(zvalue)) {
ch->handlers->write->type = PHP_CURL_BINARY;
+ } else {
+ ch->handlers->write->type = PHP_CURL_ASCII;
}
break;
case CURLOPT_WRITEFUNCTION:
@@ -1460,7 +1462,7 @@
void _php_curl_cleanup_handle(php_curl *ch)
{
if (ch->handlers->write->buf.len > 0) {
- memset(&ch->handlers->write->buf, 0, sizeof(smart_str));
+ smart_str_free(&ch->handlers->write->buf);
}
if (ch->header.str_len) {
efree(ch->header.str);
@@ -1495,7 +1497,6 @@
if (ch->handlers->write->buf.len > 0) {
smart_str_free(&ch->handlers->write->buf);
}
-
RETURN_FALSE;
}
@@ -1503,10 +1504,8 @@
if (ch->handlers->write->method == PHP_CURL_RETURN &&
ch->handlers->write->buf.len > 0) {
--ch->uses;
- if (ch->handlers->write->type != PHP_CURL_BINARY) {
- smart_str_0(&ch->handlers->write->buf);
- }
- RETURN_STRINGL(ch->handlers->write->buf.c,
ch->handlers->write->buf.len, 0);
+ smart_str_0(&ch->handlers->write->buf);
+ RETURN_STRINGL(ch->handlers->write->buf.c,
ch->handlers->write->buf.len, 1);
}
--ch->uses;
RETURN_TRUE;
@@ -1737,6 +1736,9 @@
zend_llist_clean(&ch->to_free.slist);
zend_llist_clean(&ch->to_free.post);
+ if (ch->handlers->write->buf.len > 0) {
+ smart_str_free(&ch->handlers->write->buf);
+ }
if (ch->handlers->write->func_name) {
zval_ptr_dtor(&ch->handlers->write->func_name);
}
@@ -1752,7 +1754,7 @@
if (ch->header.str_len > 0) {
efree(ch->header.str);
}
-
+
efree(ch->handlers->write);
efree(ch->handlers->write_header);
efree(ch->handlers->read);
http://cvs.php.net/viewcvs.cgi/php-src/ext/curl/multi.c?r1=1.21&r2=1.22&diff_format=u
Index: php-src/ext/curl/multi.c
diff -u php-src/ext/curl/multi.c:1.21 php-src/ext/curl/multi.c:1.22
--- php-src/ext/curl/multi.c:1.21 Sun Jan 1 13:09:48 2006
+++ php-src/ext/curl/multi.c Thu Apr 13 11:26:43 2006
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: multi.c,v 1.21 2006/01/01 13:09:48 sniper Exp $ */
+/* $Id: multi.c,v 1.22 2006/04/13 11:26:43 tony2001 Exp $ */
#define ZEND_INCLUDE_FULL_WINDOWS_HEADERS
@@ -195,11 +195,8 @@
ZEND_FETCH_RESOURCE(ch, php_curl *, &z_ch, -1, le_curl_name, le_curl);
if (ch->handlers->write->method == PHP_CURL_RETURN &&
ch->handlers->write->buf.len > 0) {
- if (ch->handlers->write->type != PHP_CURL_BINARY) {
- smart_str_0(&ch->handlers->write->buf);
- }
-
- RETURN_STRINGL(ch->handlers->write->buf.c,
ch->handlers->write->buf.len, 0);
+ smart_str_0(&ch->handlers->write->buf);
+ RETURN_STRINGL(ch->handlers->write->buf.c,
ch->handlers->write->buf.len, 1);
}
}
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php