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 Fix from Michael Kaufmann in PR bin/5...
details: https://anonhg.NetBSD.org/src/rev/2432baa73c13
branches: trunk
changeset: 365028:2432baa73c13
user: kre <kre%NetBSD.org@localhost>
date: Sat Jul 28 13:51:26 2018 +0000
description:
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).
diffstat:
external/bsd/cron/dist/entry.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diffs (27 lines):
diff -r 5acdae8728d4 -r 2432baa73c13 external/bsd/cron/dist/entry.c
--- a/external/bsd/cron/dist/entry.c Sat Jul 28 09:57:59 2018 +0000
+++ b/external/bsd/cron/dist/entry.c Sat Jul 28 13:51:26 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: entry.c,v 1.8 2018/06/14 22:04:28 christos Exp $ */
+/* $NetBSD: entry.c,v 1.9 2018/07/28 13:51:26 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.8 2018/06/14 22:04:28 christos Exp $");
+__RCSID("$NetBSD: entry.c,v 1.9 2018/07/28 13:51:26 kre Exp $");
#endif
#endif
@@ -471,7 +471,7 @@
if (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