From 963aebc260e3a9ef11d44f600cde4f13142114a8 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Sat, 23 Sep 2023 13:28:29 +0100 Subject: [PATCH] Tiny fixes in the SOCKS proxy code. Just happened to jump out at me in an eyeball inspection just now. I carefully moved all the protocol byte-value constants into a header file with mnemonic names, but I still hard-coded SOCKS4_REPLY_VERSION in the text of one diagnostic, and I got the wrong one of SOCKS5_REQUEST_VERSION and SOCKS5_REPLY_VERSION at one point in the code. Both benign (the right value was there, juste called by the wrong name). Also fixed some missing whitespace, in passing. (Probably the line it was missing from had once been squashed up closer to the right margin.) (cherry picked from commit 1cd0f1787f6c1c7d9ec0fc168ed36e54fea2c756) --- proxy/socks4.c | 4 ++-- proxy/socks5.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/proxy/socks4.c b/proxy/socks4.c index ac85ec05..8cd08d84 100644 --- a/proxy/socks4.c +++ b/proxy/socks4.c @@ -95,8 +95,8 @@ static void proxy_socks4_process_queue(ProxyNegotiator *pn) if (data[0] != SOCKS4_REPLY_VERSION) { pn->error = dupprintf("SOCKS proxy response contained reply " - "version number %d (expected 0)", - (int)data[0]); + "version number %d (expected %d)", + (int)data[0], SOCKS4_REPLY_VERSION); crStopV; } diff --git a/proxy/socks5.c b/proxy/socks5.c index 87a0bbc8..49331476 100644 --- a/proxy/socks5.c +++ b/proxy/socks5.c @@ -353,7 +353,7 @@ static void proxy_socks5_process_queue(ProxyNegotiator *pn) "SOCKS 5 CHAP authentication failed"); crStopV; } - } else if (s->chap_attr==SOCKS5_AUTH_CHAP_ATTR_CHALLENGE) { + } else if (s->chap_attr == SOCKS5_AUTH_CHAP_ATTR_CHALLENGE) { /* The CHAP challenge string. Send the response */ strbuf *response = chap_response( make_ptrlen(s->chap_buf, s->chap_attr_len), @@ -387,7 +387,7 @@ static void proxy_socks5_process_queue(ProxyNegotiator *pn) * byte[] address, with variable size (see below) * uint16 port */ - put_byte(pn->output, SOCKS5_REPLY_VERSION); + put_byte(pn->output, SOCKS5_REQUEST_VERSION); put_byte(pn->output, SOCKS_CMD_CONNECT); put_byte(pn->output, 0); /* reserved byte */