From patchwork Wed Apr 21 13:49:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Quartulli X-Patchwork-Id: 1758 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director11.mail.ord1d.rsapps.net ([172.30.191.6]) by backend30.mail.ord1d.rsapps.net with LMTP id uKcnChy6gGAyRAAAIUCqbw (envelope-from ) for ; Wed, 21 Apr 2021 19:49:48 -0400 Received: from proxy13.mail.ord1d.rsapps.net ([172.30.191.6]) by director11.mail.ord1d.rsapps.net with LMTP id 0F/fCRy6gGDQcQAAvGGmqA (envelope-from ) for ; Wed, 21 Apr 2021 19:49:48 -0400 Received: from smtp21.gate.ord1c ([172.30.191.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy13.mail.ord1d.rsapps.net with LMTPS id WFKmCRy6gGCbAwAAgjf6aA (envelope-from ) for ; Wed, 21 Apr 2021 19:49:48 -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: smtp21.gate.ord1c.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=unstable.cc X-Suspicious-Flag: YES X-Classification-ID: 411ebb4e-a2fc-11eb-81f2-a0369f0d8808-1-1 Received: from [216.105.38.7] ([216.105.38.7:47348] helo=lists.sourceforge.net) by smtp21.gate.ord1c.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 4E/F5-22722-B1AB0806; Wed, 21 Apr 2021 19:49:47 -0400 Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.92.3) (envelope-from ) id 1lZMad-0005aC-O4; Wed, 21 Apr 2021 23:49:03 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.3) (envelope-from ) id 1lZMab-0005a5-Qk for openvpn-devel@lists.sourceforge.net; Wed, 21 Apr 2021 23:49:01 +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:Cc:To:From:Sender:Reply-To: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=HZwPqDcbhxXAc1n1OKmV0GUm5PTmVdz8mwabR+HrK6k=; b=jL+goQBRXrereUC1abTuEVda6R vRKlt0Iu2KtSKHuXOLx22oU8vZdmjhBtE8VYbOaOzpSfr6TF67ThOPOGrjsPNHpJla2Dkq2KQDQoY IAIY/xyqiYFGFlD/YMPTKN/TwslYMuH5M79koxDEE3l/C87elQeoS6smmGMHRj4lrwkU=; 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:Cc:To:From :Sender:Reply-To: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=HZwPqDcbhxXAc1n1OKmV0GUm5PTmVdz8mwabR+HrK6k=; b=m i+LN8Uzmb0AYR1QmAy+yJA8B96tXeeYqLmCaB0VPMDMGmub0j48oYAJkETampehgw7dPleofnyusH wp8flKASBqczPF0PKeB3yfpK8zSI8AescdxNtbCxmNIl4us2+YaHeb0iOeK6hw6RG1aoDVHvVRj8j kzDMg9uKm8oqOt0w=; Received: from s2.neomailbox.net ([5.148.176.60]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.3) id 1lZMaW-0000AM-Qn for openvpn-devel@lists.sourceforge.net; Wed, 21 Apr 2021 23:49:01 +0000 From: Antonio Quartulli To: openvpn-devel@lists.sourceforge.net Date: Thu, 22 Apr 2021 01:49:08 +0200 Message-Id: <20210421234908.12817-1-a@unstable.cc> MIME-Version: 1.0 X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 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: openvpn.net] X-Headers-End: 1lZMaW-0000AM-Qn Subject: [Openvpn-devel] [PATCH] options: check for blanks in fingerprints and reject string if found 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: , Cc: Antonio Quartulli Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox From: Antonio Quartulli A fingerprint is not expected to contains any blank (white space), howeveri, the parser routine will still attempt parsing the octect and ignore the space. This means that a fingerprint like 5 :F0:A8:75:70:46:6E:0B:A2:31:53:88:0B:0E:8C:E4:8A:5E:BF:1E:08:16:16:41:63:2C:B5:F4:D2:73:9F:E5 will be parsed successfully. Explcitly check for spaces in the various octects, before conversion, and error out if any is found. Signed-off-by: Antonio Quartulli Acked-By: Arne Schwabe --- src/openvpn/options.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/openvpn/options.c b/src/openvpn/options.c index 817a1533..264fe383 100644 --- a/src/openvpn/options.c +++ b/src/openvpn/options.c @@ -1099,6 +1099,18 @@ parse_hash_fingerprint(const char *str, int nbytes, int msglevel, struct gc_aren bs[0] = *cp++; bs[1] = *cp++; bs[2] = 0; + + /* the format string "%x" passed to sscanf will ignore any space and + * will still try to parse the other character. However, this is not + * expected format for a fingerprint, therefore explcitly check for + * blanks in the string and error out if any is found + */ + if (bs[0] == ' ' || bs[1] == ' ') + { + msg(msglevel, "format error in hash fingerprint unexpected blank: %s", + str); + } + byte = 0; if (sscanf(bs, "%x", &byte) != 1) {