]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
ftp: fix temp write of ipv6 address
authorJay Satiro <raysatiro@yahoo.com>
Mon, 28 Aug 2023 07:09:18 +0000 (03:09 -0400)
committerJay Satiro <raysatiro@yahoo.com>
Wed, 30 Aug 2023 07:22:07 +0000 (03:22 -0400)
- During the check to differentiate between a port and IPv6 address
  without brackets, write the binary IPv6 address to an in6_addr.

Prior to this change the binary IPv6 address was erroneously written to
a sockaddr_in6 'sa6' when it should have been written to its in6_addr
member 'sin6_addr'. There's no fallout because no members of 'sa6' are
accessed before it is later overwritten.

Closes https://github.com/curl/curl/pull/11747

lib/ftp.c

index adb2ebd99c6fe688cc33477ce65ae016802e3560..e24ae9c15d1fc38b15e352e28ad1f664f5d03342 100644 (file)
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -972,7 +972,7 @@ static CURLcode ftp_state_use_port(struct Curl_easy *data,
         if(ip_end) {
           /* either ipv6 or (ipv4|domain|interface):port(-range) */
 #ifdef ENABLE_IPV6
-          if(Curl_inet_pton(AF_INET6, string_ftpport, sa6) == 1) {
+          if(Curl_inet_pton(AF_INET6, string_ftpport, &sa6->sin6_addr) == 1) {
             /* ipv6 */
             port_min = port_max = 0;
             strcpy(addr, string_ftpport);