Skip to content
Open
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
5 changes: 5 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ PHP NEWS
- BCMath:
. Added NUL-byte validation to BCMath functions. (jorgsowa)

- Curl:
. Added CURLOPT_SOCKOPTFUNCTION, CURLOPT_OPENSOCKETFUNCTION and
CURLOPT_CLOSESOCKETFUNCTION options, bridging libcurl's socket callbacks to
ext/sockets Socket objects (requires the sockets extension).

- Date:
. Update timelib to 2022.16. (Derick)

Expand Down
10 changes: 10 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,16 @@ PHP 8.6 UPGRADE NOTES
. It is now possible to define the `__debugInfo()` magic method on enums.
RFC: https://wiki.php.net/rfc/debugable-enums

- Curl:
. Added the CURLOPT_SOCKOPTFUNCTION, CURLOPT_OPENSOCKETFUNCTION and
CURLOPT_CLOSESOCKETFUNCTION options, which let userland hook into libcurl's
socket creation, configuration and teardown. The callbacks exchange
ext/sockets Socket objects, e.g. to validate the resolved address before
connecting (SSRF protection) or to set low-level socket options. These
options require the sockets extension; the new CURL_SOCKOPT_OK,
CURL_SOCKOPT_ERROR, CURL_SOCKOPT_ALREADY_CONNECTED, CURLSOCKTYPE_IPCXN and
CURLSOCKTYPE_ACCEPT constants are defined alongside them.

- Fileinfo:
. finfo_file() now works with remote streams.

Expand Down
4 changes: 4 additions & 0 deletions ext/curl/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ if test "$PHP_CURL" != "no"; then
PHP_NEW_EXTENSION([curl],
[interface.c multi.c share.c curl_file.c],
[$ext_shared])
dnl The CURLOPT_SOCKOPT/OPENSOCKET/CLOSESOCKETFUNCTION callbacks bridge to
dnl ext/sockets Socket objects (guarded by HAVE_SOCKETS). The dependency is
dnl optional: without sockets, curl still builds, just without those options.
PHP_ADD_EXTENSION_DEP(curl, sockets, true)
PHP_INSTALL_HEADERS([ext/curl], [php_curl.h])
PHP_SUBST([CURL_SHARED_LIBADD])
fi
4 changes: 4 additions & 0 deletions ext/curl/config.w32
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ if (PHP_CURL != "no") {
WARNING("zstd in curl not enabled; library not found");
}
EXTENSION("curl", "interface.c multi.c share.c curl_file.c");
// The socket callbacks (CURLOPT_SOCKOPT/OPENSOCKET/CLOSESOCKETFUNCTION)
// bridge to ext/sockets Socket objects, guarded by HAVE_SOCKETS. Optional:
// without sockets, curl still builds, just without those options.
ADD_EXTENSION_DEP('curl', 'sockets', true);
AC_DEFINE('HAVE_CURL', 1, "Define to 1 if the PHP extension 'curl' is available.");
ADD_FLAG("CFLAGS_CURL", "/D PHP_CURL_EXPORTS=1");
if (curl_location.match(/libcurl_a\.lib$/)) {
Expand Down
57 changes: 57 additions & 0 deletions ext/curl/curl.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -2327,6 +2327,63 @@
*/
const CURL_FNMATCHFUNC_NOMATCH = UNKNOWN;

#ifdef HAVE_SOCKETS
/**
* Used with CURLOPT_SOCKOPTFUNCTION, which receives a Socket wrapping the
* descriptor libcurl just created and must return one of the CURL_SOCKOPT_*
* constants below.
* @var int
* @cvalue CURLOPT_SOCKOPTFUNCTION
*/
const CURLOPT_SOCKOPTFUNCTION = UNKNOWN;
/**
* Used with CURLOPT_OPENSOCKETFUNCTION, which receives the resolved address and
* must return a Socket to use for the connection, or false to abort it.
* @var int
* @cvalue CURLOPT_OPENSOCKETFUNCTION
*/
const CURLOPT_OPENSOCKETFUNCTION = UNKNOWN;
/**
* Used with CURLOPT_CLOSESOCKETFUNCTION, which is notified when libcurl is done
* with a socket created by the open-socket callback.
* @var int
* @cvalue CURLOPT_CLOSESOCKETFUNCTION
*/
const CURLOPT_CLOSESOCKETFUNCTION = UNKNOWN;
/**
* Return value for the CURLOPT_SOCKOPTFUNCTION callback: proceed normally.
* @var int
* @cvalue CURL_SOCKOPT_OK
*/
const CURL_SOCKOPT_OK = UNKNOWN;
/**
* Return value for the CURLOPT_SOCKOPTFUNCTION callback: abort the connection.
* @var int
* @cvalue CURL_SOCKOPT_ERROR
*/
const CURL_SOCKOPT_ERROR = UNKNOWN;
/**
* Return value for the CURLOPT_SOCKOPTFUNCTION callback: the socket is already
* connected, so libcurl should skip its own connect step.
* @var int
* @cvalue CURL_SOCKOPT_ALREADY_CONNECTED
*/
const CURL_SOCKOPT_ALREADY_CONNECTED = UNKNOWN;
/**
* Purpose passed to the socket callbacks: a socket for a regular IP connection.
* @var int
* @cvalue CURLSOCKTYPE_IPCXN
*/
const CURLSOCKTYPE_IPCXN = UNKNOWN;
/**
* Purpose passed to the socket callbacks: a socket created from accept() (e.g.
* active FTP).
* @var int
* @cvalue CURLSOCKTYPE_ACCEPT
*/
const CURLSOCKTYPE_ACCEPT = UNKNOWN;
#endif

/* Available since 7.21.2 */
/**
* @var int
Expand Down
12 changes: 11 additions & 1 deletion ext/curl/curl_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions ext/curl/curl_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ typedef struct {
#if LIBCURL_VERSION_NUM >= 0x075400 /* Available since 7.84.0 */
zend_fcall_info_cache sshhostkey;
#endif
#ifdef HAVE_SOCKETS
zend_fcall_info_cache sockopt;
zend_fcall_info_cache opensocket;
zend_fcall_info_cache closesocket;
#endif
} php_curl_handlers;

struct _php_curl_error {
Expand Down
Loading
Loading