mirror of
https://github.com/php/php-src.git
synced 2025-08-18 15:08:55 +02:00
- Fixed bug #48203 (crash when CURLOPT_STDERR is set to regular file)
This commit is contained in:
parent
1dd3916370
commit
017529f11a
2 changed files with 25 additions and 2 deletions
|
@ -1689,6 +1689,20 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue, zval *retu
|
||||||
ch->handlers->read->fp = fp;
|
ch->handlers->read->fp = fp;
|
||||||
ch->handlers->read->fd = Z_LVAL_PP(zvalue);
|
ch->handlers->read->fd = Z_LVAL_PP(zvalue);
|
||||||
break;
|
break;
|
||||||
|
case CURLOPT_STDERR:
|
||||||
|
if (((php_stream *) what)->mode[0] != 'r') {
|
||||||
|
if (ch->handlers->stderr) {
|
||||||
|
zval_ptr_dtor(&ch->handlers->stderr);
|
||||||
|
}
|
||||||
|
zval_add_ref(zvalue);
|
||||||
|
ch->handlers->stderr = *zvalue;
|
||||||
|
zend_list_addref(Z_LVAL_PP(zvalue));
|
||||||
|
} else {
|
||||||
|
php_error_docref(NULL TSRMLS_CC, E_WARNING, "the provided file handle is not writable");
|
||||||
|
RETVAL_FALSE;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
/* break omitted intentionally */
|
||||||
default:
|
default:
|
||||||
error = curl_easy_setopt(ch->cp, option, fp);
|
error = curl_easy_setopt(ch->cp, option, fp);
|
||||||
break;
|
break;
|
||||||
|
@ -2334,6 +2348,11 @@ static void _php_curl_close_ex(php_curl *ch TSRMLS_DC)
|
||||||
fprintf(stderr, "DTOR CALLED, ch = %x\n", ch);
|
fprintf(stderr, "DTOR CALLED, ch = %x\n", ch);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Prevent crash inside cURL if passed file has already been closed */
|
||||||
|
if (ch->handlers->stderr && Z_REFCOUNT_P(ch->handlers->stderr) <= 0) {
|
||||||
|
curl_easy_setopt(ch->cp, CURLOPT_STDERR, stderr);
|
||||||
|
}
|
||||||
|
|
||||||
curl_easy_cleanup(ch->cp);
|
curl_easy_cleanup(ch->cp);
|
||||||
#if LIBCURL_VERSION_NUM < 0x071101
|
#if LIBCURL_VERSION_NUM < 0x071101
|
||||||
zend_llist_clean(&ch->to_free.str);
|
zend_llist_clean(&ch->to_free.str);
|
||||||
|
@ -2359,6 +2378,9 @@ static void _php_curl_close_ex(php_curl *ch TSRMLS_DC)
|
||||||
if (ch->handlers->passwd) {
|
if (ch->handlers->passwd) {
|
||||||
zval_ptr_dtor(&ch->handlers->passwd);
|
zval_ptr_dtor(&ch->handlers->passwd);
|
||||||
}
|
}
|
||||||
|
if (ch->handlers->stderr) {
|
||||||
|
zval_ptr_dtor(&ch->handlers->stderr);
|
||||||
|
}
|
||||||
if (ch->header.str_len > 0) {
|
if (ch->header.str_len > 0) {
|
||||||
efree(ch->header.str);
|
efree(ch->header.str);
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,6 +107,7 @@ typedef struct {
|
||||||
php_curl_write *write_header;
|
php_curl_write *write_header;
|
||||||
php_curl_read *read;
|
php_curl_read *read;
|
||||||
zval *passwd;
|
zval *passwd;
|
||||||
|
zval *stderr;
|
||||||
php_curl_progress *progress;
|
php_curl_progress *progress;
|
||||||
} php_curl_handlers;
|
} php_curl_handlers;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue