From patchwork Wed Sep 9 02:03:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 1430 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director12.mail.ord1d.rsapps.net ([172.27.255.53]) by backend30.mail.ord1d.rsapps.net with LMTP id yJ0OE9bEWF+3egAAIUCqbw (envelope-from ) for ; Wed, 09 Sep 2020 08:04:38 -0400 Received: from proxy4.mail.iad3a.rsapps.net ([172.27.255.53]) by director12.mail.ord1d.rsapps.net with LMTP id 0HvOEtbEWF94MQAAIasKDg (envelope-from ) for ; Wed, 09 Sep 2020 08:04:38 -0400 Received: from smtp52.gate.iad3a ([172.27.255.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy4.mail.iad3a.rsapps.net with LMTPS id AAvLC9bEWF/KRAAA8Zvu4w (envelope-from ) for ; Wed, 09 Sep 2020 08:04:38 -0400 X-Spam-Threshold: 95 X-Spam-Score: 0 X-Spam-Flag: NO X-Virus-Scanned: OK X-Orig-To: openvpnslackdevel@openvpn.net X-Originating-Ip: [216.105.38.7] Authentication-Results: smtp52.gate.iad3a.rsapps.net; iprev=pass policy.iprev="216.105.38.7"; spf=pass smtp.mailfrom="openvpn-devel-bounces@lists.sourceforge.net" smtp.helo="lists.sourceforge.net"; dkim=fail (signature verification failed) header.d=sourceforge.net; dkim=fail (signature verification failed) header.d=sf.net; dmarc=none (p=nil; dis=none) header.from=greenie.muc.de X-Suspicious-Flag: YES X-Classification-ID: a12b4cbe-f294-11ea-921f-525400a7d0a1-1-1 Received: from [216.105.38.7] ([216.105.38.7:57908] helo=lists.sourceforge.net) by smtp52.gate.iad3a.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id A9/25-08882-4D4C85F5; Wed, 09 Sep 2020 08:04:37 -0400 Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1kFypG-0006zO-JR; Wed, 09 Sep 2020 12:03:46 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kFypF-0006z2-3A for openvpn-devel@lists.sourceforge.net; Wed, 09 Sep 2020 12:03:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:Message-Id: Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=QoO+vb/8gf1nDP6rhRt3sulq16qHNwGba+Z8r41kzcY=; b=YmHtqgl8PoMFQWuOMf0/Vit8WC 2Cio9qljevjo93SzhK5OS2ZfCDtz1fn6FjIm7ZjIbNhbDSeqp/PMbuLZTS705OoXW3/6TSXCa4fCl OGw/aidZwrCSqi+U7HuYvvHoEWkcs2k8hgm737cwMU3XJmT6k9ARPvUukKN2NmocCU6M=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject:To:From: Sender:Reply-To:Cc:Content-Type:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=QoO+vb/8gf1nDP6rhRt3sulq16qHNwGba+Z8r41kzcY=; b=f WClUFlFB0+s6OR1grVu1pJ4OZ197OvxjUKiluA2Cich1usp28QlC8zCpAYQXVdeL4kphDdNt8ZRTd 3z/IC+cFVF2vvQx7lSFdqPlu7IQFJ8WKjaxHGkTa+6u+2ZYXQQCBhrHxUkMcUZxotS6lr6iUQP0MO LWrquD3uPxFE8eNc=; Received: from dhcp-174.greenie.muc.de ([193.149.48.174] helo=blue.greenie.muc.de) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2) id 1kFyp5-000Vve-Ac for openvpn-devel@lists.sourceforge.net; Wed, 09 Sep 2020 12:03:44 +0000 Received: from blue.greenie.muc.de (localhost [127.0.0.1]) by blue.greenie.muc.de (8.14.9/8.14.9) with ESMTP id 089C3K3u008521 for ; Wed, 9 Sep 2020 14:03:20 +0200 Received: (from gert@localhost) by blue.greenie.muc.de (8.15.2/8.14.9/Submit) id 089C3Kbt008520 for openvpn-devel@lists.sourceforge.net; Wed, 9 Sep 2020 14:03:20 +0200 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Wed, 9 Sep 2020 14:03:19 +0200 Message-Id: <20200909120319.8464-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. 0.0 URIBL_BLOCKED ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [URIs: muc.de] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record X-Headers-End: 1kFyp5-000Vve-Ac Subject: [Openvpn-devel] [PATCH] socks.c: fix alen for DOMAIN type addresses X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox 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 " - so when copying bytes, we need to hande "length +1" bytes. Our code totally doesn't use this variant of addresses, 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. Reported-By: tpw_rules in Trac Trac: #848 Signed-off-by: Gert Doering --- src/openvpn/socks.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/openvpn/socks.c b/src/openvpn/socks.c index 57f0cee2..aff62746 100644 --- a/src/openvpn/socks.c +++ b/src/openvpn/socks.c @@ -381,7 +381,10 @@ recv_socks_reply(socket_descriptor_t sd, break; case '\x03': /* DOMAINNAME */ - alen = (unsigned char) c; + /* RFC 1928, section 5: 1 byte length, bytes name, + * so the total "address length" is (length+1) + */ + alen = (unsigned char) c +1; break; case '\x04': /* IP V6 */