Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions ext/curl/interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -522,9 +522,11 @@ PHP_MSHUTDOWN_FUNCTION(curl)
/* {{{ curl_write */
static size_t curl_write(char *data, size_t size, size_t nmemb, void *ctx)
{
ZEND_ASSERT(size == 1);

php_curl *ch = (php_curl *) ctx;
php_curl_write *write_handler = ch->handlers.write;
size_t length = size * nmemb;
size_t length = nmemb;

#if PHP_CURL_DEBUG
fprintf(stderr, "curl_write() called\n");
Expand Down Expand Up @@ -786,6 +788,8 @@ static int curl_ssh_hostkeyfunction(void *clientp, int keytype, const char *key,
/* {{{ curl_read */
static size_t curl_read(char *data, size_t size, size_t nmemb, void *ctx)
{
ZEND_ASSERT(size == 1);

php_curl *ch = (php_curl *)ctx;
php_curl_read *read_handler = ch->handlers.read;
size_t length = 0;
Expand All @@ -808,15 +812,15 @@ static size_t curl_read(char *data, size_t size, size_t nmemb, void *ctx)
} else {
ZVAL_NULL(&argv[1]);
}
ZVAL_LONG(&argv[2], (int)size * nmemb);
ZVAL_LONG(&argv[2], (zend_long) nmemb);

ch->in_callback = true;
zend_call_known_fcc(&read_handler->fcc, &retval, /* param_count */ 3, argv, /* named_params */ NULL);
ch->in_callback = false;
if (!Z_ISUNDEF(retval)) {
_php_curl_verify_handlers(ch, /* reporterror */ true);
if (Z_TYPE(retval) == IS_STRING) {
length = MIN(size * nmemb, Z_STRLEN(retval));
length = MIN(nmemb, Z_STRLEN(retval));
memcpy(data, Z_STRVAL(retval), length);
} else if (Z_TYPE(retval) == IS_LONG) {
length = Z_LVAL_P(&retval);
Expand Down Expand Up @@ -884,9 +888,11 @@ static int curl_seek(void *clientp, curl_off_t offset, int origin)
/* {{{ curl_write_header */
static size_t curl_write_header(char *data, size_t size, size_t nmemb, void *ctx)
{
ZEND_ASSERT(size == 1);

php_curl *ch = (php_curl *) ctx;
php_curl_write *write_handler = ch->handlers.write_header;
size_t length = size * nmemb;
size_t length = nmemb;

switch (write_handler->method) {
case PHP_CURL_STDOUT:
Expand Down
Loading