Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/bsd/cron/dist Add some more "crappy error detection...



details:   https://anonhg.NetBSD.org/src/rev/cb7904c474c8
branches:  trunk
changeset: 365029:cb7904c474c8
user:      kre <kre%NetBSD.org@localhost>
date:      Sat Jul 28 13:55:08 2018 +0000

description:
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).

diffstat:

 external/bsd/cron/dist/entry.c |  6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diffs (27 lines):

diff -r 2432baa73c13 -r cb7904c474c8 external/bsd/cron/dist/entry.c
--- a/external/bsd/cron/dist/entry.c    Sat Jul 28 13:51:26 2018 +0000
+++ b/external/bsd/cron/dist/entry.c    Sat Jul 28 13:55:08 2018 +0000
@@ -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 @@
 {
        /* 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));



Home | Main Index | Thread Index | Old Index