Skip to content
Merged
Show file tree
Hide file tree
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
28 changes: 14 additions & 14 deletions ext/curl/interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -1453,11 +1453,11 @@ static int curl_fnmatch(void *ctx, const char *pattern, const char *string)
/* }}} */

/* {{{ curl_progress */
static size_t curl_progress(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow)
static int curl_progress(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow)
{
php_curl *ch = (php_curl *)clientp;
php_curl_callback *t = ch->handlers.progress;
size_t rval = 0;
int rval = 0;

#if PHP_CURL_DEBUG
fprintf(stderr, "curl_progress() called\n");
Expand Down Expand Up @@ -1818,8 +1818,8 @@ static void _php_curl_set_default_options(php_curl *ch)
{
char *cainfo;

curl_easy_setopt(ch->cp, CURLOPT_NOPROGRESS, 1);
curl_easy_setopt(ch->cp, CURLOPT_VERBOSE, 0);
curl_easy_setopt(ch->cp, CURLOPT_NOPROGRESS, 1L);
curl_easy_setopt(ch->cp, CURLOPT_VERBOSE, 0L);
curl_easy_setopt(ch->cp, CURLOPT_ERRORBUFFER, ch->err.str);
curl_easy_setopt(ch->cp, CURLOPT_WRITEFUNCTION, curl_write);
curl_easy_setopt(ch->cp, CURLOPT_FILE, (void *) ch);
Expand All @@ -1828,10 +1828,10 @@ static void _php_curl_set_default_options(php_curl *ch)
curl_easy_setopt(ch->cp, CURLOPT_HEADERFUNCTION, curl_write_header);
curl_easy_setopt(ch->cp, CURLOPT_WRITEHEADER, (void *) ch);
#ifndef ZTS
curl_easy_setopt(ch->cp, CURLOPT_DNS_USE_GLOBAL_CACHE, 1);
curl_easy_setopt(ch->cp, CURLOPT_DNS_USE_GLOBAL_CACHE, 1L);
#endif
curl_easy_setopt(ch->cp, CURLOPT_DNS_CACHE_TIMEOUT, 120);
curl_easy_setopt(ch->cp, CURLOPT_MAXREDIRS, 20); /* prevent infinite redirects */
curl_easy_setopt(ch->cp, CURLOPT_DNS_CACHE_TIMEOUT, 120L);
curl_easy_setopt(ch->cp, CURLOPT_MAXREDIRS, 20L); /* prevent infinite redirects */

cainfo = INI_STR("openssl.cafile");
if (!(cainfo && cainfo[0] != '\0')) {
Expand All @@ -1842,7 +1842,7 @@ static void _php_curl_set_default_options(php_curl *ch)
}

#ifdef ZTS
curl_easy_setopt(ch->cp, CURLOPT_NOSIGNAL, 1);
curl_easy_setopt(ch->cp, CURLOPT_NOSIGNAL, 1L);
#endif
}
/* }}} */
Expand Down Expand Up @@ -2289,7 +2289,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue, bool i
lval = zval_get_long(zvalue);
if (lval == 1) {
php_error_docref(NULL, E_NOTICE, "CURLOPT_SSL_VERIFYHOST no longer accepts the value 1, value 2 will be used instead");
error = curl_easy_setopt(ch->cp, option, 2);
error = curl_easy_setopt(ch->cp, option, 2L);
break;
}
ZEND_FALLTHROUGH;
Expand Down Expand Up @@ -2789,7 +2789,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue, bool i

case CURLOPT_FOLLOWLOCATION:
lval = zend_is_true(zvalue);
error = curl_easy_setopt(ch->cp, option, lval);
error = curl_easy_setopt(ch->cp, option, (long) lval);
break;

case CURLOPT_HEADERFUNCTION:
Expand All @@ -2807,7 +2807,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue, bool i
/* no need to build the mime structure for empty hashtables;
also works around https://github.com/curl/curl/issues/6455 */
curl_easy_setopt(ch->cp, CURLOPT_POSTFIELDS, "");
error = curl_easy_setopt(ch->cp, CURLOPT_POSTFIELDSIZE, 0);
error = curl_easy_setopt(ch->cp, CURLOPT_POSTFIELDSIZE, 0L);
} else {
return build_mime_structure_from_hash(ch, zvalue);
}
Expand Down Expand Up @@ -2871,7 +2871,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue, bool i

case CURLOPT_POSTREDIR:
lval = zval_get_long(zvalue);
error = curl_easy_setopt(ch->cp, CURLOPT_POSTREDIR, lval & CURL_REDIR_POST_ALL);
error = curl_easy_setopt(ch->cp, CURLOPT_POSTREDIR, (long) (lval & CURL_REDIR_POST_ALL));
break;

/* the following options deal with files, therefore the open_basedir check
Expand Down Expand Up @@ -2906,11 +2906,11 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue, bool i
if (zend_is_true(zvalue)) {
curl_easy_setopt(ch->cp, CURLOPT_DEBUGFUNCTION, curl_debug);
curl_easy_setopt(ch->cp, CURLOPT_DEBUGDATA, (void *)ch);
curl_easy_setopt(ch->cp, CURLOPT_VERBOSE, 1);
curl_easy_setopt(ch->cp, CURLOPT_VERBOSE, 1L);
} else {
curl_easy_setopt(ch->cp, CURLOPT_DEBUGFUNCTION, NULL);
curl_easy_setopt(ch->cp, CURLOPT_DEBUGDATA, NULL);
curl_easy_setopt(ch->cp, CURLOPT_VERBOSE, 0);
curl_easy_setopt(ch->cp, CURLOPT_VERBOSE, 0L);
}
break;

Expand Down
12 changes: 8 additions & 4 deletions ext/curl/tests/curl_setopt_ssl.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,13 @@ if ($curl_version['version_number'] < 0x074700) {
--FILE--
<?php

function check_error(CurlHandle $ch) {
function check_error(CurlHandle $ch, $expected = null) {
if (curl_errno($ch) !== 0) {
echo "CURL ERROR: " . curl_errno($ch) . "\n";
$errno = curl_errno($ch);
if (!is_null($expected)) {
$errno = $errno == $expected ? 'EXPECTED' : "UNEXPECTED(A:$errno,E:$expected)";
}
echo "CURL ERROR: " . $errno . "\n";
}
}

Expand Down Expand Up @@ -109,7 +113,7 @@ try {

$response = curl_exec($ch);
check_response($response, $clientCertSubject);
check_error($ch);
check_error($ch, curl_version()['version_number'] < 0x081000 ? 58 : 43);
curl_close($ch);

echo "\n";
Expand Down Expand Up @@ -203,7 +207,7 @@ bool(true)
bool(true)
bool(true)
client cert subject not in response
CURL ERROR: 58
CURL ERROR: EXPECTED

case 4: client cert and key from file
bool(true)
Expand Down
Loading