]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: fix divide-by-zero
authorQuentin Young <qlyoung@cumulusnetworks.com>
Wed, 14 Jun 2017 14:06:01 +0000 (14:06 +0000)
committerQuentin Young <qlyoung@cumulusnetworks.com>
Wed, 14 Jun 2017 15:08:58 +0000 (15:08 +0000)
x % 0 = FPE

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
zebra/irdp_interface.c
zebra/irdp_main.c

index 5cabe7e62f7339e427cdef0d806708df992ca4b7..6ea14b305885d04fc533542f7c388101bb8b570a 100644 (file)
@@ -476,18 +476,14 @@ DEFUN (ip_irdp_minadvertinterval,
   zi=ifp->info;
   irdp=&zi->irdp;
 
-  if( (unsigned) atoi(argv[idx_number]->arg) <= irdp->MaxAdvertInterval) {
+  if((unsigned) atoi(argv[idx_number]->arg) < irdp->MaxAdvertInterval) {
       irdp->MinAdvertInterval = atoi(argv[idx_number]->arg);
-
       return CMD_SUCCESS;
   }
-
-  vty_out (vty, "ICMP warning maxadvertinterval is greater or equal than minadvertinterval%s",
-            VTY_NEWLINE);
-
-  vty_out (vty, "Please correct!%s",
-            VTY_NEWLINE);
-  return CMD_WARNING;
+  else {
+      vty_out (vty, "%% MinAdvertInterval must be less than MaxAdvertInterval");
+      return CMD_WARNING;
+  }
 }
 
 DEFUN (ip_irdp_maxadvertinterval,
@@ -506,19 +502,14 @@ DEFUN (ip_irdp_maxadvertinterval,
   zi=ifp->info;
   irdp=&zi->irdp;
 
-
-  if( irdp->MinAdvertInterval <= (unsigned) atoi(argv[idx_number]->arg) ) {
-    irdp->MaxAdvertInterval = atoi(argv[idx_number]->arg);
-
+  if(irdp->MinAdvertInterval < (unsigned) atoi(argv[idx_number]->arg)) {
+      irdp->MaxAdvertInterval = atoi(argv[idx_number]->arg);
       return CMD_SUCCESS;
   }
-
-  vty_out (vty, "ICMP warning maxadvertinterval is greater or equal than minadvertinterval%s",
-            VTY_NEWLINE);
-
-  vty_out (vty, "Please correct!%s",
-            VTY_NEWLINE);
-  return CMD_WARNING;
+  else {
+      vty_out (vty, "%% MaxAdvertInterval must be greater than MinAdvertInterval");
+      return CMD_WARNING;
+  }
 }
 
 /* DEFUN needs to be fixed for negative ranages...
index 7fa4ad4cbe8b5716aecc7070405e7d6d5936bfd9..8f1647c9db99cfb0efa4464d57f7666cbe9fbdd3 100644 (file)
@@ -234,7 +234,8 @@ int irdp_send_thread(struct thread *t_advert)
       }
 
   tmp = irdp->MaxAdvertInterval-irdp->MinAdvertInterval;
-  timer =  (random () % tmp ) + 1;
+  assert (tmp > 0);
+  timer = (random () % tmp) + 1;
   timer = irdp->MinAdvertInterval + timer;
 
   if(irdp->irdp_sent <  MAX_INITIAL_ADVERTISEMENTS &&