Skip to content

Commit 7f29e7c

Browse files
dedalqqsgolemon
authored andcommitted
Interpretation of curl_setopt values for boolean parameters
1 parent e926bf6 commit 7f29e7c

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

ext/curl/interface.c

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2302,8 +2302,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
23022302
error = curl_easy_setopt(ch->cp, option, lval);
23032303
break;
23042304
case CURLOPT_SAFE_UPLOAD:
2305-
lval = zval_get_long(zvalue);
2306-
if (lval == 0) {
2305+
if (!zend_is_true(zvalue)) {
23072306
php_error_docref(NULL, E_WARNING, "Disabling safe uploads is no longer supported");
23082307
return FAILURE;
23092308
}
@@ -2639,13 +2638,11 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
26392638
break;
26402639

26412640
case CURLOPT_FOLLOWLOCATION:
2642-
lval = zval_get_long(zvalue);
2641+
lval = zend_is_true(zvalue);
26432642
#if LIBCURL_VERSION_NUM < 0x071304
2644-
if (PG(open_basedir) && *PG(open_basedir)) {
2645-
if (lval != 0) {
2646-
php_error_docref(NULL, E_WARNING, "CURLOPT_FOLLOWLOCATION cannot be activated when an open_basedir is set");
2647-
return FAILURE;
2648-
}
2643+
if (lval && PG(open_basedir) && *PG(open_basedir)) {
2644+
php_error_docref(NULL, E_WARNING, "CURLOPT_FOLLOWLOCATION cannot be activated when an open_basedir is set");
2645+
return FAILURE;
26492646
}
26502647
#endif
26512648
error = curl_easy_setopt(ch->cp, option, lval);
@@ -2801,8 +2798,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
28012798
break;
28022799

28032800
case CURLOPT_RETURNTRANSFER:
2804-
lval = zval_get_long(zvalue);
2805-
if (lval) {
2801+
if (zend_is_true(zvalue)) {
28062802
ch->handlers->write->method = PHP_CURL_RETURN;
28072803
} else {
28082804
ch->handlers->write->method = PHP_CURL_STDOUT;
@@ -2878,8 +2874,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
28782874
}
28792875

28802876
case CURLINFO_HEADER_OUT:
2881-
lval = zval_get_long(zvalue);
2882-
if (lval == 1) {
2877+
if (zend_is_true(zvalue)) {
28832878
curl_easy_setopt(ch->cp, CURLOPT_DEBUGFUNCTION, curl_debug);
28842879
curl_easy_setopt(ch->cp, CURLOPT_DEBUGDATA, (void *)ch);
28852880
curl_easy_setopt(ch->cp, CURLOPT_VERBOSE, 1);

0 commit comments

Comments
 (0)