From 4118c4b57394bbb712c9635d5e8bacac67bb6137 Mon Sep 17 00:00:00 2001 From: 0x1eef <0x1eef@protonmail.com> Date: Sat, 26 Aug 2023 00:31:53 -0300 Subject: [PATCH] Fix edgecase (4...4 is invalid) --- src/isinetaddr.c | 2 +- test/isinetaddr_test.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/isinetaddr.c b/src/isinetaddr.c index 8e3358e..a2582ea 100644 --- a/src/isinetaddr.c +++ b/src/isinetaddr.c @@ -17,7 +17,7 @@ isinetaddr(const char *str) for (size_t l = 0; l < len; l++) { if (str[l] == '.') { - if (octets == 2 && digits == 0) { + if (buflen == 0) { return 0; } else if (!in_range(buf, buflen)) { return 0; diff --git a/test/isinetaddr_test.c b/test/isinetaddr_test.c index c5e43e2..d5b752c 100644 --- a/test/isinetaddr_test.c +++ b/test/isinetaddr_test.c @@ -25,6 +25,7 @@ const char *invalid[] = { ".......", "192.2.2.", "...4", + "4...4", NULL };