diff --git a/src/isinetaddr.c b/src/isinetaddr.c index 05a75fd..a157172 100644 --- a/src/isinetaddr.c +++ b/src/isinetaddr.c @@ -20,6 +20,7 @@ isinetaddr(const char *str) char buf[4]; int i = 0, j = 0, k = 0; size_t len = (str == NULL ? 0 : strnlen(str, 16)); + for (size_t l = 0; l < len; l++) { if (str[l] == '.') { if (inrange(buf)) { @@ -42,6 +43,11 @@ isinetaddr(const char *str) return 0; } } - return j == 3 && i <= 12 && inrange(buf); + if (k == 3 && j == 3) { + if (!inrange(buf)) { + return 0; + } + } + return j == 3 && i <= 12; }