Source-Changes-HG archive

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

[src/netbsd-8]: src/external/bsd/cron/dist Pull up following revision(s) (req...



details:   https://anonhg.NetBSD.org/src/rev/9ff9b9e157b6
branches:  netbsd-8
changeset: 435179:9ff9b9e157b6
user:      martin <martin%NetBSD.org@localhost>
date:      Tue Aug 07 13:24:59 2018 +0000

description:
Pull up following revision(s) (requested by kre in ticket #959):

        external/bsd/cron/dist/entry.c: revision 1.9,1.10

Fix from Michael Kaufmann in PR bin/53476

Do modulus using unsigned arith, and then convert the result to
int, rather than converting the arc4random() result to int (which
might be negative) and performing a modulus on that (with a
potentially negative answer).

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 |  8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diffs (31 lines):

diff -r fae231e20a26 -r 9ff9b9e157b6 external/bsd/cron/dist/entry.c
--- a/external/bsd/cron/dist/entry.c    Tue Aug 07 13:19:51 2018 +0000
+++ b/external/bsd/cron/dist/entry.c    Tue Aug 07 13:24:59 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: entry.c,v 1.7 2015/11/20 23:43:52 christos Exp $       */
+/*     $NetBSD: entry.c,v 1.7.8.1 2018/08/07 13:24:59 martin 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.7 2015/11/20 23:43:52 christos Exp $");
+__RCSID("$NetBSD: entry.c,v 1.7.8.1 2018/08/07 13:24:59 martin Exp $");
 #endif
 #endif
 
@@ -450,10 +450,10 @@
 {
        /* Kind of crappy error detection, but...
         */
-       if (low >= high)
+       if (low < 0 || low >= high)
                return low;
        else
-               return (int)arc4random() % (high - low + 1) + low;
+               return (int)(arc4random() % (unsigned)((high - low + 1) + low));
 }
 
 static int



Home | Main Index | Thread Index | Old Index