From: Ilia Alshanetsky Date: Thu, 21 May 2009 12:52:05 +0000 (+0000) Subject: Fixed bug #48207 (CURLOPT_(FILE|WRITEHEADER options do not error out when X-Git-Tag: php-5.3.0RC3~182 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=44fe1bf83fe0f9f9ec62ee435c3cfc1e823215f8;p=php Fixed bug #48207 (CURLOPT_(FILE|WRITEHEADER options do not error out when working with a non-writable stream) --- diff --git a/ext/curl/interface.c b/ext/curl/interface.c index 89a3c6c3bb..c814fa0e83 100644 --- a/ext/curl/interface.c +++ b/ext/curl/interface.c @@ -1649,12 +1649,24 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue, zval *retu 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));