summaryrefslogtreecommitdiff
path: root/lib/ip.c
diff options
context:
space:
mode:
authorMaria Matejka <mq@ucw.cz>2019-08-14 12:29:04 +0200
committerMaria Matejka <mq@ucw.cz>2020-05-01 15:19:12 +0200
commita1b61a271af40a9d6ef0837424ab2c98d29f1575 (patch)
tree7f12d374e2ee2efd04147b43a3281997d52f3787 /lib/ip.c
parentd65a926a67749f8e8ffb6df9b3e2e123669b0656 (diff)
IPv6 address parser: fail on incomplete addresses
Diffstat (limited to 'lib/ip.c')
-rw-r--r--lib/ip.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/ip.c b/lib/ip.c
index 2d195160..fcc72caf 100644
--- a/lib/ip.c
+++ b/lib/ip.c
@@ -264,6 +264,9 @@ ip6_pton(const char *a, ip6_addr *o)
int i, j, k, l, hfil;
const char *start;
+ if (!a[0]) /* Empty string check */
+ return 0;
+
if (a[0] == ':') /* Leading :: */
{
if (a[1] != ':')
@@ -333,6 +336,8 @@ ip6_pton(const char *a, ip6_addr *o)
for (; i>=hfil; i--)
words[i] = 0;
}
+ else if (i != 8) /* Incomplete address */
+ return 0;
/* Convert the address to ip6_addr format */
for (i=0; i<4; i++)