commit
c45da5abbc
2 changed files with 17 additions and 16 deletions
|
@ -30,28 +30,20 @@ isinetaddr6(const char *str)
|
|||
char new_str[MAX_STRLEN];
|
||||
return isinetaddr6(expand(str, len, new_str, i));
|
||||
} else if (str[i] == SEP) {
|
||||
if (digitlen < MAX_DIGITLEN) {
|
||||
return 0;
|
||||
} else {
|
||||
digitlen = 0;
|
||||
hextets++;
|
||||
}
|
||||
digitlen = 0;
|
||||
} else if (isxdigit(str[i])) {
|
||||
if (digitlen == MAX_DIGITLEN) {
|
||||
digitlen++;
|
||||
hexdigits++;
|
||||
if (digitlen > MAX_DIGITLEN) {
|
||||
return 0;
|
||||
} else {
|
||||
digitlen++;
|
||||
hexdigits++;
|
||||
} else if (str[i-1] == SEP) {
|
||||
hextets++;
|
||||
}
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (hextets == MAX_HEXTETS) {
|
||||
return hexdigits <= MAX_HEXDIGITS && digitlen == MAX_DIGITLEN;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
return hextets == MAX_HEXTETS && hexdigits <= MAX_HEXDIGITS;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
const char *valid[] = {
|
||||
/* valid IPv6 (single colon)*/
|
||||
"2001:DB80:0000:0000:0008:800:200C:417A",
|
||||
"0000:0000:0000:0000:0000:0000:0000:0001",
|
||||
"2001:0db8:85a3:0000:0000:8a2e:0370:7334",
|
||||
"fe80:0000:0000:0000:0202:b3ff:fe1e:8329",
|
||||
|
@ -12,6 +13,13 @@ const char *valid[] = {
|
|||
"1234:5678:9abc:def0:face:face:b00c:0ffe",
|
||||
"2001:19f0:5401:0000:0000:ffff:1e61:face",
|
||||
"dead:beef:cafe:babe:affe:8a2e:0370:7334",
|
||||
"2001:DB8:0:0:8:800:200C:417A",
|
||||
"0000:0000:0000:0000:0000:0000:0000:0",
|
||||
"FEDC:BA98:7654:3210:FEDC:BA98:7654:3210",
|
||||
"0:0:0:0:0:0:0:1",
|
||||
"FF01:0:0:0:0:0:0:101",
|
||||
"0:0:0:0:0:0:0:0",
|
||||
"2001:DB8:0:0:8:800:200C:417A",
|
||||
|
||||
/* valid IPv6 (double colon) */
|
||||
"fe80::c001:a0ff:fe12:3456",
|
||||
|
@ -25,6 +33,7 @@ const char *valid[] = {
|
|||
"0000:0000:0000:0000:0000:0000:0000:00::",
|
||||
"2001:0db8:85a3:0000:0000::8a2e:0370:7334",
|
||||
"2001::5",
|
||||
"FF01::101",
|
||||
"::ffff:192.168.2.1",
|
||||
"::FFFF:192.168.2.1",
|
||||
"::",
|
||||
|
@ -34,8 +43,8 @@ const char *valid[] = {
|
|||
const char *invalid[] = {
|
||||
/* invalid IPv6 (single colon) */
|
||||
"0000:0000:0000:0000:0000:0000:0000:000Z",
|
||||
"0000:0000:0000:0000:0000:0000:0000:0",
|
||||
"0000:0000:0000:0000:0000:0000:0000:",
|
||||
"2001:DB8:0:Z:8:800:200C:417A",
|
||||
|
||||
/* invalid IPv6 (double colon) */
|
||||
":::", "2001:::1", "2001:::1::",
|
||||
|
|
Loading…
Reference in a new issue