]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
options: check for blanks in fingerprints and reject string if found
authorAntonio Quartulli <antonio@openvpn.net>
Wed, 21 Apr 2021 23:49:08 +0000 (01:49 +0200)
committerGert Doering <gert@greenie.muc.de>
Mon, 26 Apr 2021 15:14:24 +0000 (17:14 +0200)
A fingerprint is not expected to contains any blank (white space),
however, the parser routine will still attempt parsing the octect
and ignore the space.

This means that a fingerprint like
  "5 :F0: 8:75:70:46:6E:(...)"
will be parsed successfully.

Explicitly check for spaces in the various octets, before conversion,
and error out if any is 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>
src/openvpn/options.c

index 84da0456e86cc163265134b297ae04215c543a50..2a5b1393ed097162864bc3c3c90d5183b8cf08dc 100644 (file)
@@ -1101,6 +1101,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 explictly 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)
         {