From ef8b1151b6c9e8d05a8e5482b505c27de16b6dba Mon Sep 17 00:00:00 2001 From: millert Date: Mon, 8 May 2023 15:18:31 +0000 Subject: [PATCH] cron: bounds check the high and low bounds for in a random range. The bounds are checked for normal ranges in set_element() but in the case of random ranges this is too late. As a result, a random range with an invalid high/low bounds would only result in a syntax error if the randomized value was out of bounds. This means the entry would be "randomly" rejected by cron or crontab. OK kn@ --- usr.sbin/cron/entry.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/usr.sbin/cron/entry.c b/usr.sbin/cron/entry.c index 0d7a8526dfd..c3f04b1afcc 100644 --- a/usr.sbin/cron/entry.c +++ b/usr.sbin/cron/entry.c @@ -1,4 +1,4 @@ -/* $OpenBSD: entry.c,v 1.55 2023/05/07 13:43:13 millert Exp $ */ +/* $OpenBSD: entry.c,v 1.56 2023/05/08 15:18:31 millert Exp $ */ /* * Copyright 1988,1990,1993,1994 by Paul Vixie @@ -513,6 +513,11 @@ get_range(bitstr_t *bits, int low, int high, const char *names[], return (EOF); } + /* we must perform the bounds checking ourselves + */ + if (num1 < low || num2 > high) + return (EOF); + if (ch == '/') { /* randomize the step value instead of num1 */ -- 2.20.1