iliaa Thu May 21 12:52:59 2009 UTC
Modified files:
/php-src/ext/curl interface.c
Log:
MFB: Fixed bug #48207 (CURLOPT_(FILE|WRITEHEADER options do not error out
when working with a non-writable stream)
http://cvs.php.net/viewvc.cgi/php-src/ext/curl/interface.c?r1=1.165&r2=1.166&diff_format=u
Index: php-src/ext/curl/interface.c
diff -u php-src/ext/curl/interface.c:1.165 php-src/ext/curl/interface.c:1.166
--- php-src/ext/curl/interface.c:1.165 Wed May 20 09:26:03 2009
+++ php-src/ext/curl/interface.c Thu May 21 12:52:59 2009
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: interface.c,v 1.165 2009/05/20 09:26:03 tony2001 Exp $ */
+/* $Id: interface.c,v 1.166 2009/05/21 12:52:59 iliaa Exp $ */
#define ZEND_INCLUDE_FULL_WINDOWS_HEADERS
@@ -1665,12 +1665,24 @@
error = CURLE_OK;
switch (option) {
case CURLOPT_FILE:
- ch->handlers->write->fp = fp;
- ch->handlers->write->method =
PHP_CURL_FILE;
+ if (((php_stream *) what)->mode[0] !=
'r') {
+ ch->handlers->write->fp = fp;
+ ch->handlers->write->method =
PHP_CURL_FILE;
+ } else {
+ php_error_docref(NULL
TSRMLS_CC, E_WARNING, "the provided file handle is not writable");
+ RETVAL_FALSE;
+ return 1;
+ }
break;
case CURLOPT_WRITEHEADER:
- ch->handlers->write_header->fp = fp;
- ch->handlers->write_header->method =
PHP_CURL_FILE;
+ if (((php_stream *) what)->mode[0] !=
'r') {
+ ch->handlers->write_header->fp
= fp;
+
ch->handlers->write_header->method = PHP_CURL_FILE;
+ } else {
+ php_error_docref(NULL
TSRMLS_CC, E_WARNING, "the provided file handle is not writable");
+ RETVAL_FALSE;
+ return 1;
+ }
break;
case CURLOPT_INFILE:
zend_list_addref(Z_LVAL_PP(zvalue));
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php