Commit f9ded55a authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Protect against overflow when computing metrics.

Reported by Gabriel Kerneis.
parent 0ae7d995
......@@ -974,7 +974,7 @@ flushupdates(struct network *net)
continue;
if(!route_interferes(route, net)) {
metric =
route->refmetric +
(int)route->refmetric +
(diversity_factor * route->cost / 128) / 256 +
route->add_metric;
metric = MAX(metric, route->refmetric + 1);
......
......@@ -44,7 +44,7 @@ struct route {
static inline int
route_metric(const struct route *route)
{
int m = route->refmetric + route->cost + route->add_metric;
int m = (int)route->refmetric + route->cost + route->add_metric;
return MIN(m, INFINITY);
}
......
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