From 75dbfb7166ab3d821528e0852f4a6d894c4f8536 Mon Sep 17 00:00:00 2001 From: 0x1eef <0x1eef@protonmail.com> Date: Sun, 31 Mar 2024 06:25:52 -0300 Subject: [PATCH] Avoid indexing 'str' with a negative index On OpenBSD - this can cause a crash. --- src/isinetaddr4.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/isinetaddr4.c b/src/isinetaddr4.c index 20b955e..95f5adc 100644 --- a/src/isinetaddr4.c +++ b/src/isinetaddr4.c @@ -35,7 +35,7 @@ isinetaddr4(const char *str) digits++; if (!within_range(buf)) { return false; - } else if (str[i-1] == SEP) { + } else if (i > 0 && str[i-1] == SEP) { octets++; } }