[Openvpn-devel] options: check for blanks in fingerprints and reject string if found
| Message ID | 20210421234908.12817-1-a@unstable.cc |
|---|---|
| State | Accepted |
| Headers |
Return-Path: <openvpn-devel-bounces@lists.sourceforge.net> 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 <openvpn-devel-bounces@lists.sourceforge.net>) for <patchwork@openvpn.net>; 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 <openvpn-devel-bounces@lists.sourceforge.net>) for <patchwork@openvpn.net>; 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 <openvpn-devel-bounces@lists.sourceforge.net>) for <patchwork@openvpn.net>; 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 <openvpn-devel-bounces@lists.sourceforge.net>) (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 <openvpn-devel-bounces@lists.sourceforge.net>) 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 <a@unstable.cc>) 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 <a@unstable.cc> 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: <openvpn-devel.lists.sourceforge.net> List-Unsubscribe: <https://lists.sourceforge.net/lists/options/openvpn-devel>, <mailto:openvpn-devel-request@lists.sourceforge.net?subject=unsubscribe> List-Archive: <http://sourceforge.net/mailarchive/forum.php?forum_name=openvpn-devel> List-Post: <mailto:openvpn-devel@lists.sourceforge.net> List-Help: <mailto:openvpn-devel-request@lists.sourceforge.net?subject=help> List-Subscribe: <https://lists.sourceforge.net/lists/listinfo/openvpn-devel>, <mailto:openvpn-devel-request@lists.sourceforge.net?subject=subscribe> Cc: Antonio Quartulli <antonio@openvpn.net> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox |
| Series |
[Openvpn-devel] options: check for blanks in fingerprints and reject string if found
|
|
Commit Message
Antonio Quartulli
April 21, 2021, 1:49 p.m. UTC
From: Antonio Quartulli <antonio@openvpn.net> 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 <antonio@openvpn.net> --- src/openvpn/options.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
Comments
Am 22.04.21 um 01:49 schrieb Antonio Quartulli: > From: Antonio Quartulli <antonio@openvpn.net> > > 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. Explicitly > > Signed-off-by: Antonio Quartulli <antonio@openvpn.net> > --- > 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 explicitly > + * 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) > { > I would not have spend the time to fix this but since Antonio done it: Acked-By: Arne Schwabe <arne@rfc2549.org>
Your patch has been applied to the master branch.
That said, I find this function pretty insane, tbh. Parsing a sequence
of double-digit hex bytes should be doable in half the lines of code,
and without needing to copy bytes to temp buffers to pass to scanf()...
(https://stackoverflow.com/questions/10156409/convert-hex-string-char-to-int)
commit 9e71cf13134c10bb7e952e3dadbcc79884f60b93
Author: Antonio Quartulli
Date: Thu Apr 22 01:49:08 2021 +0200
options: check for blanks in fingerprints and reject string if found
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20210421234908.12817-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22182.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
--
kind regards,
Gert Doering
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) {