Skip to content

Commit 94b192c

Browse files
committed
ext/curl: Fix CURLOPT_PREREQFUNCTION to not continue on error conditions
This is a follow-up to phpGH-13255. When the `CURLOPT_PREREQFUNCTION` callback does not return any value or return an invalid value, we throw a `ValueError` or a `TypeError` exception. However, it does not prevent the Curl request from going forward because our default return value is `CURL_PREREQFUNC_OK`. This changes the default value to `CURL_PREREQFUNC_ABORT`.
1 parent f2dbad6 commit 94b192c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

ext/curl/interface.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -722,13 +722,13 @@ static size_t curl_xferinfo(void *clientp, curl_off_t dltotal, curl_off_t dlnow,
722722
static int curl_prereqfunction(void *clientp, char *conn_primary_ip, char *conn_local_ip, int conn_primary_port, int conn_local_port)
723723
{
724724
php_curl *ch = (php_curl *)clientp;
725-
int rval = CURL_PREREQFUNC_OK;
725+
int rval = CURL_PREREQFUNC_ABORT;
726726

727-
// when CURLOPT_PREREQFUNCTION is set to null, curl_prereqfunction still
727+
// When CURLOPT_PREREQFUNCTION is set to null, curl_prereqfunction still
728728
// gets called. Return CURL_PREREQFUNC_OK immediately in this case to avoid
729729
// zend_call_known_fcc() with an uninitialized FCC.
730730
if (!ZEND_FCC_INITIALIZED(ch->handlers.prereq)) {
731-
return rval;
731+
return CURL_PREREQFUNC_OK;
732732
}
733733

734734
#if PHP_CURL_DEBUG

0 commit comments

Comments
 (0)