router: fix arithmetic exception fault
authorHans Dedecker <dedeckeh@gmail.com>
Mon, 20 Feb 2017 16:19:06 +0000 (17:19 +0100)
committerHans Dedecker <dedeckeh@gmail.com>
Mon, 20 Feb 2017 16:19:06 +0000 (17:19 +0100)
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
src/router.c

index dd3f09cebba6d72c64935c90188b394def3bfc34..ffafb9451f3c106e0c594c033cc4fc3b48d54ed8 100644 (file)
@@ -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;
 }