In get_number(), reject values that are so large that they are
interpreted as negative numbers. In set_range(), step values smaller
than one or larger than the "stop" value are ignored. This prevents
bit_nset() from being called with out-of-range values.
Bug found by Dave G. of Supernetworks.
-/* $OpenBSD: entry.c,v 1.59 2023/07/19 21:26:02 millert Exp $ */
+/* $OpenBSD: entry.c,v 1.60 2024/08/19 15:08:21 millert Exp $ */
/*
* Copyright 1988,1990,1993,1994 by Paul Vixie
/* got a number, check for valid terminator */
if (!strchr(terms, ch))
goto bad;
- *numptr = atoi(temp);
+ i = atoi(temp);
+ if (i < 0)
+ goto bad;
+ *numptr = i;
return (ch);
}
start -= low;
stop -= low;
- if (step == 1) {
+ if (step <= 1 || step > stop) {
bit_nset(bits, start, stop);
} else {
for (i = start; i <= stop; i += step)