]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
cf-socket: use the right byte order for ports in bindlocal
authorDaniel Stenberg <daniel@haxx.se>
Sat, 20 Sep 2025 14:56:14 +0000 (16:56 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Sat, 20 Sep 2025 15:34:18 +0000 (17:34 +0200)
Reported in Joshua's sarif data

Closes #18641

lib/cf-socket.c

index 365ddb62a144ff4b3d629bbffab434f725d6fb44..2f0429efeae627a6f225ea6b1890e7f5055e683f 100644 (file)
@@ -790,10 +790,10 @@ static CURLcode bindlocal(struct Curl_easy *data, struct connectdata *conn,
       infof(data, "Bind to local port %d failed, trying next", port - 1);
       /* We reuse/clobber the port variable here below */
       if(sock->sa_family == AF_INET)
-        si4->sin_port = ntohs(port);
+        si4->sin_port = htons(port);
 #ifdef USE_IPV6
       else
-        si6->sin6_port = ntohs(port);
+        si6->sin6_port = htons(port);
 #endif
     }
     else