Fix edgecase (4...4 is invalid)

This commit is contained in:
0x1eef 2023-08-26 00:31:53 -03:00
parent b0d7141379
commit 4118c4b573
2 changed files with 2 additions and 1 deletions

View file

@ -17,7 +17,7 @@ isinetaddr(const char *str)
for (size_t l = 0; l < len; l++) { for (size_t l = 0; l < len; l++) {
if (str[l] == '.') { if (str[l] == '.') {
if (octets == 2 && digits == 0) { if (buflen == 0) {
return 0; return 0;
} else if (!in_range(buf, buflen)) { } else if (!in_range(buf, buflen)) {
return 0; return 0;

View file

@ -25,6 +25,7 @@ const char *invalid[] = {
".......", ".......",
"192.2.2.", "192.2.2.",
"...4", "...4",
"4...4",
NULL NULL
}; };