]> git.ipfire.org Git - thirdparty/openvpn.git/commit
socks.c: fix alen for DOMAIN type addresses, bump up buffer sizes
authorGert Doering <gert@greenie.muc.de>
Wed, 9 Sep 2020 12:22:23 +0000 (14:22 +0200)
committerGert Doering <gert@greenie.muc.de>
Mon, 14 Sep 2020 09:18:49 +0000 (11:18 +0200)
commitc7f0d7b95bff05b0a5ddab15318cd53fcc91d60a
tree4cfa399d2ae91d409691f98792ae6ddbec25a432
parent2f0be578e6385941c8135acefd9ef99a6c23c973
socks.c: fix alen for DOMAIN type addresses, bump up buffer sizes

When a SOCKS5 server sends back a reply, it encodes an "address",
which can be IPv4 (4 bytes), IPv6 (16 bytes) or "a domain name",
which has a lenght (1 byte) and "a string of length <length>" - so
when copying bytes, we need to hande "length +1" bytes.

Our code totally doesn't use this variant of addresses on reception,
but since this has been pointed out by "tpw_rules" in Trac, fix it,
so if/when someone works on this again, the foundation is correct.

While at it, increase buffer size used for sending to handle domain
names longer than 122 characters (length was already checked, so a
longer name would not overflow but just "not work").

v2: increase buf[] len in recv_socks_reply() from 22 to 270 so it
    is large enough to actually copy a domain name

v3: increase buf[] len in establish_socks_proxy_passthru() from 128 to
    270, to handle long domain names in queries

Reported-By: tpw_rules in Trac
Trac: #848

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <20200909122223.9222-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20928.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit eebeaa02367d247fc2549df3edf8e598c58c3572)
src/openvpn/socks.c