Skip to content

Commit

Permalink
ext/curl: Fix CURLOPT_PREREQFUNCTION to not continue on error condi…
Browse files Browse the repository at this point in the history
…tions

This is a follow-up to GH-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`.
  • Loading branch information
Ayesh committed Nov 14, 2024
1 parent f2dbad6 commit 94b192c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions ext/curl/interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -722,13 +722,13 @@ static size_t curl_xferinfo(void *clientp, curl_off_t dltotal, curl_off_t dlnow,
static int curl_prereqfunction(void *clientp, char *conn_primary_ip, char *conn_local_ip, int conn_primary_port, int conn_local_port)
{
php_curl *ch = (php_curl *)clientp;
int rval = CURL_PREREQFUNC_OK;
int rval = CURL_PREREQFUNC_ABORT;

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

#if PHP_CURL_DEBUG
Expand Down

0 comments on commit 94b192c

Please sign in to comment.