Prevent division by zero through (malformed) RLQ value
authorHenning Rogge <henning.rogge@fkie.fraunhofer.de>
Wed, 22 Aug 2018 07:48:31 +0000 (09:48 +0200)
committerHenning Rogge <henning.rogge@fkie.fraunhofer.de>
Wed, 22 Aug 2018 07:48:31 +0000 (09:48 +0200)
src/nhdp/ff_dat_metric/ff_dat_metric.c

index 49fac98..59a5482 100644 (file)
@@ -782,6 +782,10 @@ _get_lossrate_cost_factor(struct ff_dat_if_config *ifconfig, struct nhdp_link *l
     loss_exponent--;
   }
 
     loss_exponent--;
   }
 
+  if (success_scaled_by_1000 == 0) {
+    return 1000ll * DATFF_FRAME_SUCCESS_RANGE;
+  }
+
   loss_by_1000 =  (1000ll * 1000ll) / success_scaled_by_1000;
 
   /* hysteresis */
   loss_by_1000 =  (1000ll * 1000ll) / success_scaled_by_1000;
 
   /* hysteresis */