From 7801b53db3a868af57968cdeaf299fb0f545d79f Mon Sep 17 00:00:00 2001 From: kre Date: Sat, 28 Jul 2018 13:55:08 +0000 Subject: [PATCH] Add some more "crappy error detection" - the low value of the range of random_with_range() must not be negative (or now we are doing unsigned modulus we might generate a very big result). --- external/bsd/cron/dist/entry.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/external/bsd/cron/dist/entry.c b/external/bsd/cron/dist/entry.c index e4092d434bed..648d817577d6 100644 --- a/external/bsd/cron/dist/entry.c +++ b/external/bsd/cron/dist/entry.c @@ -1,4 +1,4 @@ -/* $NetBSD: entry.c,v 1.9 2018/07/28 13:51:26 kre Exp $ */ +/* $NetBSD: entry.c,v 1.10 2018/07/28 13:55:08 kre Exp $ */ /* * Copyright 1988,1990,1993,1994 by Paul Vixie @@ -26,7 +26,7 @@ #if 0 static char rcsid[] = "Id: entry.c,v 1.17 2004/01/23 18:56:42 vixie Exp"; #else -__RCSID("$NetBSD: entry.c,v 1.9 2018/07/28 13:51:26 kre Exp $"); +__RCSID("$NetBSD: entry.c,v 1.10 2018/07/28 13:55:08 kre Exp $"); #endif #endif @@ -468,7 +468,7 @@ random_with_range(int low, int high) { /* Kind of crappy error detection, but... */ - if (low >= high) + if (low < 0 || low >= high) return low; else return (int)(arc4random() % (unsigned)((high - low + 1) + low));