connectd: handle IPv6 correctly.

Untested, but the current code is clearly wrong (caught by gcc-4.8 -O3).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2019-05-26 13:27:55 +09:30
parent c091a4ee40
commit 9820d0664b
1 changed files with 6 additions and 5 deletions

View File

@ -45,8 +45,8 @@ static struct io_plan *connect_finish2(struct io_conn *conn,
struct connecting_socks *connect)
{
status_io(LOG_IO_IN, "proxy",
(connect->buffer + SIZE_OF_RESPONSE - SIZE_OF_IPV4_RESPONSE),
SIZE_OF_IPV6_RESPONSE - SIZE_OF_RESPONSE - SIZE_OF_IPV4_RESPONSE);
connect->buffer + SIZE_OF_RESPONSE + SIZE_OF_IPV4_RESPONSE,
SIZE_OF_IPV6_RESPONSE - SIZE_OF_IPV4_RESPONSE);
status_trace("Now try LN connect out for host %s", connect->host);
return connection_out(conn, connect->connect);
}
@ -59,11 +59,12 @@ static struct io_plan *connect_finish(struct io_conn *conn,
if ( connect->buffer[1] == '\0') {
if ( connect->buffer[3] == SOCKS_TYP_IPV6) {
/* Read rest of response */
return io_read(conn,
(connect->buffer + SIZE_OF_RESPONSE -
SIZE_OF_IPV4_RESPONSE),
connect->buffer + SIZE_OF_RESPONSE +
SIZE_OF_IPV4_RESPONSE,
SIZE_OF_IPV6_RESPONSE -
SIZE_OF_RESPONSE - SIZE_OF_IPV4_RESPONSE,
SIZE_OF_IPV4_RESPONSE,
&connect_finish2, connect);
} else if ( connect->buffer[3] == SOCKS_TYP_IPV4) {