mirror of
https://github.com/curl/curl.git
synced 2026-04-15 01:51:41 +03:00
bindlocal: don't use a random port if port number would wrap
Earlier if CURLOPT_LOCALPORT + CURLOPT_LOCALPORTRANGE would go past port 65535 the code would fall back to random port rather than giving up. Closes #8862
This commit is contained in:
parent
542c78dda7
commit
1b3dcaed9f
1 changed files with 3 additions and 1 deletions
|
|
@ -470,8 +470,10 @@ static CURLcode bindlocal(struct Curl_easy *data,
|
|||
}
|
||||
|
||||
if(--portnum > 0) {
|
||||
infof(data, "Bind to local port %hu failed, trying next", port);
|
||||
port++; /* try next port */
|
||||
if(port == 0)
|
||||
break;
|
||||
infof(data, "Bind to local port %hu failed, trying next", port - 1);
|
||||
/* We re-use/clobber the port variable here below */
|
||||
if(sock->sa_family == AF_INET)
|
||||
si4->sin_port = ntohs(port);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue