]> www.infradead.org Git - users/dwmw2/openconnect.git/commitdiff
parse_hex: avoid zero length allocation
authorNikos Mavrogiannopoulos <nmav@redhat.com>
Thu, 12 Nov 2020 13:59:33 +0000 (14:59 +0100)
committerNikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
Tue, 17 Nov 2020 12:53:13 +0000 (13:53 +0100)
Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
oath.c

diff --git a/oath.c b/oath.c
index 3224b9d3eff6b3c6eef5d9ec3e1dba5e86ab7917..de553f75de20664225d891e3fc93c6c39dc78678 100644 (file)
--- a/oath.c
+++ b/oath.c
@@ -132,6 +132,9 @@ static char *parse_hex(const char *tok, int len)
 {
        unsigned char *data, *p;
 
+       if (len <= 1)
+               return NULL;
+
        data = malloc((len + 1) / 2);
        if (!data)
                return NULL;