iliaa Wed, 30 Sep 2009 02:34:17 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=288973
Log: Fixed bug #49517 (cURL's CURLOPT_FILE prevents file from being deleted after fclose). Bug: http://bugs.php.net/49517 (Verified) cURL's CURLOPT_FILE prevents file from being deleted after fclose Changed paths: U php/php-src/branches/PHP_5_2/NEWS U php/php-src/branches/PHP_5_2/ext/curl/interface.c U php/php-src/branches/PHP_5_2/ext/curl/php_curl.h U php/php-src/branches/PHP_5_3/NEWS U php/php-src/branches/PHP_5_3/ext/curl/interface.c U php/php-src/branches/PHP_5_3/ext/curl/php_curl.h U php/php-src/trunk/ext/curl/interface.c U php/php-src/trunk/ext/curl/php_curl.h
Modified: php/php-src/branches/PHP_5_2/NEWS =================================================================== --- php/php-src/branches/PHP_5_2/NEWS 2009-09-29 23:50:57 UTC (rev 288972) +++ php/php-src/branches/PHP_5_2/NEWS 2009-09-30 02:34:17 UTC (rev 288973) @@ -13,6 +13,8 @@ mbstring.strict_mode is turned on). (Moriyoshi) - Fixed bug #49531 (CURLOPT_INFILESIZE sometimes causes warning "CURLPROTO_FILE cannot be set"). (Felipe) +- Fixed bug #49517 (cURL's CURLOPT_FILE prevents file from being deleted after + fclose). (Ilia) - Fixed bug #49354 (mb_strcut() cuts wrong length when offset is in the middle of a multibyte character). (Moriyoshi) - Fixed bug #49528 (UTF-16 strings prefixed by BOMs wrondly converted). Modified: php/php-src/branches/PHP_5_2/ext/curl/interface.c =================================================================== --- php/php-src/branches/PHP_5_2/ext/curl/interface.c 2009-09-29 23:50:57 UTC (rev 288972) +++ php/php-src/branches/PHP_5_2/ext/curl/interface.c 2009-09-30 02:34:17 UTC (rev 288973) @@ -1228,10 +1228,22 @@ dupch->cp = cp; dupch->uses = 0; + if (ch->handlers->write->stream) { + Z_ADDREF_P(dupch->handlers->write->stream); + dupch->handlers->write->stream = ch->handlers->write->stream; + } dupch->handlers->write->method = ch->handlers->write->method; dupch->handlers->write->type = ch->handlers->write->type; + if (ch->handlers->read->stream) { + Z_ADDREF_P(ch->handlers->read->stream); + } + dupch->handlers->read->stream = ch->handlers->read->stream; dupch->handlers->read->method = ch->handlers->read->method; dupch->handlers->write_header->method = ch->handlers->write_header->method; + if (ch->handlers->write_header->stream) { + Z_ADDREF_P(ch->handlers->write_header->stream); + } + dupch->handlers->write_header->stream = ch->handlers->write_header->stream; dupch->handlers->write->fp = ch->handlers->write->fp; dupch->handlers->write_header->fp = ch->handlers->write_header->fp; @@ -1457,9 +1469,10 @@ switch (option) { case CURLOPT_FILE: if (((php_stream *) what)->mode[0] != 'r' || ((php_stream *) what)->mode[1] == '+') { - zend_list_addref(Z_LVAL_PP(zvalue)); + Z_ADDREF_PP(zvalue); ch->handlers->write->fp = fp; ch->handlers->write->method = PHP_CURL_FILE; + ch->handlers->write->stream = *zvalue; } else { php_error_docref(NULL TSRMLS_CC, E_WARNING, "the provided file handle is not writable"); RETVAL_FALSE; @@ -1468,9 +1481,10 @@ break; case CURLOPT_WRITEHEADER: if (((php_stream *) what)->mode[0] != 'r' || ((php_stream *) what)->mode[1] == '+') { - zend_list_addref(Z_LVAL_PP(zvalue)); + Z_ADDREF_PP(zvalue); ch->handlers->write_header->fp = fp; ch->handlers->write_header->method = PHP_CURL_FILE; + ch->handlers->write_header->stream = *zvalue; } else { php_error_docref(NULL TSRMLS_CC, E_WARNING, "the provided file handle is not writable"); RETVAL_FALSE; @@ -1478,9 +1492,10 @@ } break; case CURLOPT_INFILE: - zend_list_addref(Z_LVAL_PP(zvalue)); + Z_ADDREF_PP(zvalue); ch->handlers->read->fp = fp; ch->handlers->read->fd = Z_LVAL_PP(zvalue); + ch->handlers->read->stream = *zvalue; break; case CURLOPT_STDERR: if (((php_stream *) what)->mode[0] != 'r' || ((php_stream *) what)->mode[1] == '+') { @@ -2129,6 +2144,16 @@ efree(ch->header.str); } + if (ch->handlers->write_header->stream) { + zval_ptr_dtor(&ch->handlers->write_header->stream); + } + if (ch->handlers->write->stream) { + zval_ptr_dtor(&ch->handlers->write->stream); + } + if (ch->handlers->read->stream) { + zval_ptr_dtor(&ch->handlers->read->stream); + } + efree(ch->handlers->write); efree(ch->handlers->write_header); efree(ch->handlers->read); Modified: php/php-src/branches/PHP_5_2/ext/curl/php_curl.h =================================================================== --- php/php-src/branches/PHP_5_2/ext/curl/php_curl.h 2009-09-29 23:50:57 UTC (rev 288972) +++ php/php-src/branches/PHP_5_2/ext/curl/php_curl.h 2009-09-30 02:34:17 UTC (rev 288973) @@ -86,6 +86,7 @@ smart_str buf; int method; int type; + zval *stream; } php_curl_write; typedef struct { @@ -94,6 +95,7 @@ FILE *fp; long fd; int method; + zval *stream; } php_curl_read; typedef struct { Modified: php/php-src/branches/PHP_5_3/NEWS =================================================================== --- php/php-src/branches/PHP_5_3/NEWS 2009-09-29 23:50:57 UTC (rev 288972) +++ php/php-src/branches/PHP_5_3/NEWS 2009-09-30 02:34:17 UTC (rev 288973) @@ -17,8 +17,9 @@ - Fixed bug #49630 (imap_listscan function missing). (Felipe) - Fixed bug #49531 (CURLOPT_INFILESIZE sometimes causes warning "CURLPROTO_FILE cannot be set"). (Felipe) +- Fixed bug #49517 (cURL's CURLOPT_FILE prevents file from being deleted after + fclose). (Ilia) - ?? ??? 2009, PHP 5.3.1RC? <- WHY IS THIS HERE? Gonna be released after 5.3.1 or what?? - Upgraded bundled sqlite to version 3.6.18. (Ilia) - Restored shebang line check to CGI sapi (not checked by scanner anymore). Modified: php/php-src/branches/PHP_5_3/ext/curl/interface.c =================================================================== --- php/php-src/branches/PHP_5_3/ext/curl/interface.c 2009-09-29 23:50:57 UTC (rev 288972) +++ php/php-src/branches/PHP_5_3/ext/curl/interface.c 2009-09-30 02:34:17 UTC (rev 288973) @@ -1509,10 +1509,22 @@ dupch->cp = cp; dupch->uses = 0; + if (ch->handlers->write->stream) { + Z_ADDREF_P(dupch->handlers->write->stream); + dupch->handlers->write->stream = ch->handlers->write->stream; + } dupch->handlers->write->method = ch->handlers->write->method; dupch->handlers->write->type = ch->handlers->write->type; + if (ch->handlers->read->stream) { + Z_ADDREF_P(ch->handlers->read->stream); + } + dupch->handlers->read->stream = ch->handlers->read->stream; dupch->handlers->read->method = ch->handlers->read->method; dupch->handlers->write_header->method = ch->handlers->write_header->method; + if (ch->handlers->write_header->stream) { + Z_ADDREF_P(ch->handlers->write_header->stream); + } + dupch->handlers->write_header->stream = ch->handlers->write_header->stream; dupch->handlers->write->fp = ch->handlers->write->fp; dupch->handlers->write_header->fp = ch->handlers->write_header->fp; @@ -1767,9 +1779,10 @@ switch (option) { case CURLOPT_FILE: if (((php_stream *) what)->mode[0] != 'r' || ((php_stream *) what)->mode[1] == '+') { - zend_list_addref(Z_LVAL_PP(zvalue)); + Z_ADDREF_PP(zvalue); ch->handlers->write->fp = fp; ch->handlers->write->method = PHP_CURL_FILE; + ch->handlers->write->stream = *zvalue; } else { php_error_docref(NULL TSRMLS_CC, E_WARNING, "the provided file handle is not writable"); RETVAL_FALSE; @@ -1778,9 +1791,10 @@ break; case CURLOPT_WRITEHEADER: if (((php_stream *) what)->mode[0] != 'r' || ((php_stream *) what)->mode[1] == '+') { - zend_list_addref(Z_LVAL_PP(zvalue)); + Z_ADDREF_PP(zvalue); ch->handlers->write_header->fp = fp; ch->handlers->write_header->method = PHP_CURL_FILE; + ch->handlers->write_header->stream = *zvalue; } else { php_error_docref(NULL TSRMLS_CC, E_WARNING, "the provided file handle is not writable"); RETVAL_FALSE; @@ -1788,9 +1802,10 @@ } break; case CURLOPT_INFILE: - zend_list_addref(Z_LVAL_PP(zvalue)); + Z_ADDREF_PP(zvalue); ch->handlers->read->fp = fp; ch->handlers->read->fd = Z_LVAL_PP(zvalue); + ch->handlers->read->stream = *zvalue; break; case CURLOPT_STDERR: if (((php_stream *) what)->mode[0] != 'r' || ((php_stream *) what)->mode[1] == '+') { @@ -2477,6 +2492,16 @@ efree(ch->header.str); } + if (ch->handlers->write_header->stream) { + zval_ptr_dtor(&ch->handlers->write_header->stream); + } + if (ch->handlers->write->stream) { + zval_ptr_dtor(&ch->handlers->write->stream); + } + if (ch->handlers->read->stream) { + zval_ptr_dtor(&ch->handlers->read->stream); + } + efree(ch->handlers->write); efree(ch->handlers->write_header); efree(ch->handlers->read); Modified: php/php-src/branches/PHP_5_3/ext/curl/php_curl.h =================================================================== --- php/php-src/branches/PHP_5_3/ext/curl/php_curl.h 2009-09-29 23:50:57 UTC (rev 288972) +++ php/php-src/branches/PHP_5_3/ext/curl/php_curl.h 2009-09-30 02:34:17 UTC (rev 288973) @@ -86,6 +86,7 @@ smart_str buf; int method; int type; + zval *stream; } php_curl_write; typedef struct { @@ -94,6 +95,7 @@ FILE *fp; long fd; int method; + zval *stream; } php_curl_read; typedef struct { Modified: php/php-src/trunk/ext/curl/interface.c =================================================================== --- php/php-src/trunk/ext/curl/interface.c 2009-09-29 23:50:57 UTC (rev 288972) +++ php/php-src/trunk/ext/curl/interface.c 2009-09-30 02:34:17 UTC (rev 288973) @@ -1527,10 +1527,22 @@ dupch->cp = cp; dupch->uses = 0; + if (ch->handlers->write->stream) { + Z_ADDREF_P(dupch->handlers->write->stream); + dupch->handlers->write->stream = ch->handlers->write->stream; + } dupch->handlers->write->method = ch->handlers->write->method; dupch->handlers->write->type = ch->handlers->write->type; + if (ch->handlers->read->stream) { + Z_ADDREF_P(ch->handlers->read->stream); + } + dupch->handlers->read->stream = ch->handlers->read->stream; dupch->handlers->read->method = ch->handlers->read->method; dupch->handlers->write_header->method = ch->handlers->write_header->method; + if (ch->handlers->write_header->stream) { + Z_ADDREF_P(ch->handlers->write_header->stream); + } + dupch->handlers->write_header->stream = ch->handlers->write_header->stream; dupch->handlers->write->fp = ch->handlers->write->fp; dupch->handlers->write_header->fp = ch->handlers->write_header->fp; @@ -1785,9 +1797,10 @@ switch (option) { case CURLOPT_FILE: if (((php_stream *) what)->mode[0] != 'r' || ((php_stream *) what)->mode[1] == '+') { - zend_list_addref(Z_LVAL_PP(zvalue)); + Z_ADDREF_PP(zvalue); ch->handlers->write->fp = fp; ch->handlers->write->method = PHP_CURL_FILE; + ch->handlers->write->stream = *zvalue; } else { php_error_docref(NULL TSRMLS_CC, E_WARNING, "the provided file handle is not writable"); RETVAL_FALSE; @@ -1796,9 +1809,10 @@ break; case CURLOPT_WRITEHEADER: if (((php_stream *) what)->mode[0] != 'r' || ((php_stream *) what)->mode[1] == '+') { - zend_list_addref(Z_LVAL_PP(zvalue)); + Z_ADDREF_PP(zvalue); ch->handlers->write_header->fp = fp; ch->handlers->write_header->method = PHP_CURL_FILE; + ch->handlers->write_header->stream = *zvalue; } else { php_error_docref(NULL TSRMLS_CC, E_WARNING, "the provided file handle is not writable"); RETVAL_FALSE; @@ -1806,9 +1820,10 @@ } break; case CURLOPT_INFILE: - zend_list_addref(Z_LVAL_PP(zvalue)); + Z_ADDREF_PP(zvalue); ch->handlers->read->fp = fp; ch->handlers->read->fd = Z_LVAL_PP(zvalue); + ch->handlers->read->stream = *zvalue; break; case CURLOPT_STDERR: if (((php_stream *) what)->mode[0] != 'r' || ((php_stream *) what)->mode[1] == '+') { @@ -2545,6 +2560,16 @@ efree(ch->header.str); } + if (ch->handlers->write_header->stream) { + zval_ptr_dtor(&ch->handlers->write_header->stream); + } + if (ch->handlers->write->stream) { + zval_ptr_dtor(&ch->handlers->write->stream); + } + if (ch->handlers->read->stream) { + zval_ptr_dtor(&ch->handlers->read->stream); + } + efree(ch->handlers->write); efree(ch->handlers->write_header); efree(ch->handlers->read); Modified: php/php-src/trunk/ext/curl/php_curl.h =================================================================== --- php/php-src/trunk/ext/curl/php_curl.h 2009-09-29 23:50:57 UTC (rev 288972) +++ php/php-src/trunk/ext/curl/php_curl.h 2009-09-30 02:34:17 UTC (rev 288973) @@ -86,6 +86,7 @@ smart_str buf; int method; int type; + zval *stream; } php_curl_write; typedef struct { @@ -94,6 +95,7 @@ FILE *fp; long fd; int method; + zval *stream; } php_curl_read; typedef struct {
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php