summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorHans Dedecker <dedeckeh@gmail.com>2017-02-20 17:19:06 +0100
committerHans Dedecker <dedeckeh@gmail.com>2017-02-20 17:19:06 +0100
commitba0cac09cc22c911c1c20c2947dd23f795599627 (patch)
treeac872970b041786e15c1a77944f16832f968d691
parent3495f179bd901d6d232e0dbf35444ebe483fdfd9 (diff)
router: fix arithmetic exception fault
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
-rw-r--r--src/router.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/router.c b/src/router.c
index dd3f09c..ffafb94 100644
--- a/src/router.c
+++ b/src/router.c
@@ -233,7 +233,8 @@ static int calc_adv_interval(struct interface *iface, uint32_t minvalid,
minival = (*maxival >= 9 ? *maxival/3 : *maxival);
odhcpd_urandom(&msecs, sizeof(msecs));
- msecs = (labs(msecs) % ((*maxival - minival)*1000)) + minival*1000;
+ msecs = (labs(msecs) % ((*maxival != minival) ? (*maxival - minival)*1000 : 500)) +
+ minival*1000;
return msecs;
}