Commit 95236b03 authored by Michael Graff's avatar Michael Graff
Browse files

make the returned value sane in all cases

parent 60a0cad8
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: random.c,v 1.11 2000/09/06 02:39:59 explorer Exp $ */
/* $Id: random.c,v 1.12 2000/09/08 00:06:39 explorer Exp $ */
#include <config.h>
......@@ -65,11 +65,16 @@ isc_random_jitter(isc_uint32_t max, isc_uint32_t min, isc_uint32_t jitter) {
REQUIRE(jitter > 0);
if (min >= max)
return (min);
/*
* Don't allow jitter to be more than max - min.
*/
if (jitter > max - min)
jitter = max - min;
if (jitter == 0)
return (min);
val = rand() % jitter;
return (max - val);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment