From cefdd26d62e01878b8e8acbb78a8fcc477a63fd9 Mon Sep 17 00:00:00 2001 From: dartraiden Date: Thu, 12 Dec 2024 09:52:45 +0300 Subject: libcurl: update to 8.11.1 --- libs/libcurl/src/cf-socket.c | 47 +++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 22 deletions(-) (limited to 'libs/libcurl/src/cf-socket.c') diff --git a/libs/libcurl/src/cf-socket.c b/libs/libcurl/src/cf-socket.c index 89f19cb317..c2e633f7e6 100644 --- a/libs/libcurl/src/cf-socket.c +++ b/libs/libcurl/src/cf-socket.c @@ -600,36 +600,39 @@ static CURLcode bindlocal(struct Curl_easy *data, struct connectdata *conn, if(!iface && !host && !port) /* no local kind of binding was requested */ return CURLE_OK; + else if(iface && (strlen(iface) >= 255) ) + return CURLE_BAD_FUNCTION_ARGUMENT; memset(&sa, 0, sizeof(struct Curl_sockaddr_storage)); - if(iface && (strlen(iface) < 255) ) { + if(iface || host) { char myhost[256] = ""; int done = 0; /* -1 for error, 1 for address found */ if2ip_result_t if2ip_result = IF2IP_NOT_FOUND; - /* interface */ #ifdef SO_BINDTODEVICE - /* - * This binds the local socket to a particular interface. This will - * force even requests to other local interfaces to go out the external - * interface. Only bind to the interface when specified as interface, - * not just as a hostname or ip address. - * - * The interface might be a VRF, eg: vrf-blue, which means it cannot be - * converted to an IP address and would fail Curl_if2ip. Simply try to - * use it straight away. - */ - if(setsockopt(sockfd, SOL_SOCKET, SO_BINDTODEVICE, - iface, (curl_socklen_t)strlen(iface) + 1) == 0) { - /* This is often "errno 1, error: Operation not permitted" if you are - * not running as root or another suitable privileged user. If it - * succeeds it means the parameter was a valid interface and not an IP - * address. Return immediately. - */ - if(!host_input) { - infof(data, "socket successfully bound to interface '%s'", iface); - return CURLE_OK; + if(iface) { + /* + * This binds the local socket to a particular interface. This will + * force even requests to other local interfaces to go out the external + * interface. Only bind to the interface when specified as interface, + * not just as a hostname or ip address. + * + * The interface might be a VRF, eg: vrf-blue, which means it cannot be + * converted to an IP address and would fail Curl_if2ip. Simply try to + * use it straight away. + */ + if(setsockopt(sockfd, SOL_SOCKET, SO_BINDTODEVICE, + iface, (curl_socklen_t)strlen(iface) + 1) == 0) { + /* This is often "errno 1, error: Operation not permitted" if you are + * not running as root or another suitable privileged user. If it + * succeeds it means the parameter was a valid interface and not an IP + * address. Return immediately. + */ + if(!host_input) { + infof(data, "socket successfully bound to interface '%s'", iface); + return CURLE_OK; + } } } #endif -- cgit v1.2.3