Commit e028b9ff authored by Wayne Davison's avatar Wayne Davison

Call bind() with the right ai_addr/ai_addrlen info.

parent 9c07d253
...@@ -80,8 +80,7 @@ static int establish_proxy_connection(int fd, char *host, int port) ...@@ -80,8 +80,7 @@ static int establish_proxy_connection(int fd, char *host, int port)
} }
/* throw away the rest of the HTTP header */ /* throw away the rest of the HTTP header */
while (1) { while (1) {
for (cp = buffer; cp < &buffer[sizeof (buffer) - 1]; for (cp = buffer; cp < &buffer[sizeof (buffer) - 1]; cp++) {
cp++) {
if (read(fd, cp, 1) != 1) { if (read(fd, cp, 1) != 1) {
rprintf(FERROR, "failed to read from proxy: %s\n", rprintf(FERROR, "failed to read from proxy: %s\n",
strerror(errno)); strerror(errno));
...@@ -103,8 +102,7 @@ static int establish_proxy_connection(int fd, char *host, int port) ...@@ -103,8 +102,7 @@ static int establish_proxy_connection(int fd, char *host, int port)
* Try to set the local address for a newly-created socket. Return -1 * Try to set the local address for a newly-created socket. Return -1
* if this fails. * if this fails.
**/ **/
int try_bind_local(int s, int try_bind_local(int s, int ai_family, int ai_socktype,
int ai_family, int ai_socktype,
const char *bind_address) const char *bind_address)
{ {
int error; int error;
...@@ -322,8 +320,8 @@ static int open_socket_in(int type, int port, const char *bind_address, ...@@ -322,8 +320,8 @@ static int open_socket_in(int type, int port, const char *bind_address,
setsockopt(s, SOL_SOCKET, SO_REUSEADDR, setsockopt(s, SOL_SOCKET, SO_REUSEADDR,
(char *)&one, sizeof one); (char *)&one, sizeof one);
/* now we've got a socket - we need to bind it */ /* Now we've got a socket - we need to bind it. */
if (bind(s, all_ai->ai_addr, all_ai->ai_addrlen) < 0) { if (bind(s, resp->ai_addr, resp->ai_addrlen) < 0) {
/* Nope, try another */ /* Nope, try another */
close(s); close(s);
continue; continue;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment