Fix reading domain name of incorrect length

Fixed a bug that causes SOCKS 5 proxy 59 error due to reading hostname of incorrect length.
This commit is contained in:
netms7 2021-11-25 00:32:41 +01:00 committed by GitHub
parent bd1dcacf73
commit 6a15a576b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -195,8 +195,13 @@ int clientnegotiate(struct chain * redir, struct clientparam * param, struct soc
break; break;
return 59; return 59;
case 3: case 3:
if (sockgetlinebuf(param, SERVER, buf, 1, EOF, conf.timeouts[CHAIN_TO]) != 1) return 59; if (sockgetlinebuf(param, SERVER, buf, 1, EOF, conf.timeouts[CHAIN_TO]) != 1)
if (sockgetlinebuf(param, SERVER, buf, (unsigned)(buf[0]+2), EOF, conf.timeouts[CHAIN_TO]) != (unsigned)(buf[0]+2)) return 59; return 59;
const unsigned hostname_length = buf[0];
if (sockgetlinebuf(param, SERVER, buf, hostname_length + 2, EOF, conf.timeouts[CHAIN_TO]) != hostname_length + 2)
return 59;
break; break;
case 4: case 4:
if (sockgetlinebuf(param, SERVER, buf, 18, EOF, conf.timeouts[CHAIN_TO]) == 18) if (sockgetlinebuf(param, SERVER, buf, 18, EOF, conf.timeouts[CHAIN_TO]) == 18)