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>
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)
{