Make sure you dont overflow MaxInt64

This commit is contained in:
Milos Gajdos 2019-10-23 17:42:04 +01:00
parent 35729092e0
commit 776284b187
No known key found for this signature in database
GPG Key ID: 8B31058CC55DFD4F

View File

@ -767,7 +767,12 @@ func (n *network) processCtrlChan(listener tunnel.Listener) {
Metric: event.Route.Metric,
}
// calculate route metric and add to the advertised metric
route.Metric += n.getRouteMetric(event.Route.Router, event.Route.Gateway)
// we need to make sure we do not overflow math.MaxInt64
if metric := n.getRouteMetric(event.Route.Router, event.Route.Gateway); metric != math.MaxInt64 {
route.Metric += n.getRouteMetric(event.Route.Router, event.Route.Gateway)
} else {
route.Metric = metric
}
// create router event
e := &router.Event{
Type: router.EventType(event.Type),