Avoid indexing 'str' with a negative index

On OpenBSD - this can cause a crash.
This commit is contained in:
0x1eef 2024-03-31 06:25:52 -03:00
parent 1c2778131f
commit 75dbfb7166

View file

@ -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++;
}
}