Improve error message on short read from socks proxy
PATCH 1/1 Improve error message on short read from socks proxy
From: Selva Nair <[email protected]...>
--- src/openvpn/socks.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
src/openvpn/socks.c +6 -1
@@ -357,11 +357,16 @@ recv_socks_reply(socket_descriptor_t sd, size =recv (sd, &c,1 ,MSG_NOSIGNAL );/* error? */ -if (size !=1 ) +if (size <0 ) {msg (D_LINK_ERRORS |M_ERRNO ,"recv_socks_reply: TCP port read failed on recv()" );return false; } +else if (size ==0 ) + { +msg (D_LINK_ERRORS ,"ERROR: recv_socks_reply: empty response from socks server" ); +return false; + }if (len ==3 ) {
Signature · 1 line
2.34.1
Thanks, this change makes sense. I have not actively tried to provoke it (like, by connecting to a "fake SOCKS server" that will trigger it), but the change is obviously an improvement to "if it's not ==1, it must be a TCP error!").
I do test the SOCKS code in my t_client runs, but all my SOCKS servers are well-behaved (and the regular t_client cannot handle "expect failure" cases anyway). Room for improvement.
So, I've tested this on a regular client using a well-behaved SOCKS proxy, and as expected, "it does not break anything" :-)
Your patch has been applied to the master and release/2.6 branch.
commit 172640189277c940439d24fd31a59b8faffd0b3e (master) commit c20a15844829a186b4d5256b0e8d76b8eb074845 (release/2.6)
Author: Selva Nair Date: Sat Mar 18 10:13:30 2023 -0400
Improve error message on short read from socks proxy
Signed-off-by: Selva Nair <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg26437.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
Quoted 8 lines
Thanks, this change makes sense. I have not actively tried to provoke it (like, by connecting to a "fake SOCKS server" that will trigger it), but the change is obviously an improvement to "if it's not ==1, it must be a TCP error!").
An easy way to "provoke" this is to use openssh proxy (say, -D 1080) and use it to proxy to a udp server. SSH will close the connection as it does not
support udp association. Probably it should return one of the socks5 error code instead, but doesn't. Even if it did, our recv_socks_reply() is not capable of
handling such errors.
Selva
Hi,
Quoted 5 lines · Selva Nair
Quoted 4 lines
Thanks, this change makes sense. I have not actively tried to provoke it (like, by connecting to a "fake SOCKS server" that will trigger it), but the change is obviously an improvement to "if it's not ==1, it must be a TCP error!").
Quoted 7 lines
An easy way to "provoke" this is to use openssh proxy (say, -D 1080) and use it to proxy to a udp server. SSH will close the connection as it does not
support udp association. Probably it should return one of the socks5 error code instead, but doesn't. Even if it did, ourrecv_socks_reply()is not capable of
handling such errors.
Ah, this is helpful. I did use "socks -D" for the very first t_client.sh "test with SOCKS", but I found this cumbersome for regular use (need to ensure the session is up, etc.) I went for "dante" instead - v4, v6, UDP, TCP. And a config language worse than OpenVPN... *cough*.
gert
Signature · 6 lines
"If was one thing all people took for granted, was conviction that if you
feed honest figures into a computer, honest figures come out. Never doubted
it myself till I met a computer with a sense of humor."
Robert A. Heinlein, The Moon is a Harsh Mistress
Gert Doering - Munich, Germany [email protected]...