From 799b301af41ccbd5d14529185f9e2979497607ca Mon Sep 17 00:00:00 2001 From: 0x1eef <0x1eef@protonmail.com> Date: Fri, 25 Aug 2023 21:12:26 -0300 Subject: [PATCH] Avoid calling inrange when we don't have any integers in 'buf' --- src/isinetaddr.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/isinetaddr.c b/src/isinetaddr.c index 04b6f31..b0acc39 100644 --- a/src/isinetaddr.c +++ b/src/isinetaddr.c @@ -23,9 +23,9 @@ isinetaddr(const char *str) for (size_t l = 0; l < len; l++) { if (str[l] == '.') { - if (!inrange(buf)) { + if (j == 1 && i == 0) { return 0; - } else if(j == 1 && i == 0) { + } else if (k > 0 && !inrange(buf)) { return 0; } else { k = 0; @@ -45,11 +45,10 @@ isinetaddr(const char *str) return 0; } } - if (k == 3 && j == 3) { + if (j == 3 && k == 3) { if (!inrange(buf)) { return 0; } } return j == 3 && k > 0 && i <= 12; } -