From 9820d0664bed85c100df4caea57c5d29dee67185 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Sun, 26 May 2019 13:27:55 +0930 Subject: [PATCH] connectd: handle IPv6 correctly. Untested, but the current code is clearly wrong (caught by gcc-4.8 -O3). Signed-off-by: Rusty Russell --- connectd/tor.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/connectd/tor.c b/connectd/tor.c index ea74d66e3..db9471a4f 100644 --- a/connectd/tor.c +++ b/connectd/tor.c @@ -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) {