diff --git a/src/isinetaddr.c b/src/isinetaddr.c index c5ceb71..09adf25 100644 --- a/src/isinetaddr.c +++ b/src/isinetaddr.c @@ -32,9 +32,13 @@ isinetaddr(const char *str) return 0; } } else if (isdigit(str[l])) { - buf[k++] = str[l]; - buf[k] = '\0'; - i++; + if (k == 3) { + return 0; + } else { + buf[k++] = str[l]; + buf[k] = '\0'; + i++; + } } else { return 0; } diff --git a/test/isinetaddr_test.c b/test/isinetaddr_test.c index f0a9a13..0c5e555 100644 --- a/test/isinetaddr_test.c +++ b/test/isinetaddr_test.c @@ -17,7 +17,7 @@ const char *invalid[] = { "192.168.1.1.", "192.168.1.1..", "192.168.1.1a", - //"555555555555555555555555555555555555", + "555555555555555555555555555555555555", "", NULL };