diff options
author | Donald Sharp <sharpd@nvidia.com> | 2022-02-18 16:55:16 +0100 |
---|---|---|
committer | Donald Sharp <sharpd@nvidia.com> | 2022-02-22 17:11:31 +0100 |
commit | c960cb28f72bce27dbf0aad75e1a41b85cf1a614 (patch) | |
tree | 1a00cc7ec7f7409e3ce1c54720313442b44fc02e /eigrpd | |
parent | bfdd: Fix overflow possibility with time statements (diff) | |
download | frr-c960cb28f72bce27dbf0aad75e1a41b85cf1a614.tar.xz frr-c960cb28f72bce27dbf0aad75e1a41b85cf1a614.zip |
eigrpd: Up convert to uint64_t before doing math
Intentionally up convert uint8_t and uint32_t values
to a uint64_t before doing math to make Coverity happy.
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
Diffstat (limited to 'eigrpd')
-rw-r--r-- | eigrpd/eigrp_metric.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/eigrpd/eigrp_metric.c b/eigrpd/eigrp_metric.c index ea62f9d1b..7ccafd4fa 100644 --- a/eigrpd/eigrp_metric.c +++ b/eigrpd/eigrp_metric.c @@ -86,19 +86,24 @@ eigrp_metric_t eigrp_calculate_metrics(struct eigrp *eigrp, */ if (eigrp->k_values[0]) - composite += (eigrp->k_values[0] * metric.bandwidth); + composite += ((eigrp_metric_t)eigrp->k_values[0] * + (eigrp_metric_t)metric.bandwidth); if (eigrp->k_values[1]) - composite += ((eigrp->k_values[1] * metric.bandwidth) - / (256 - metric.load)); + composite += (((eigrp_metric_t)eigrp->k_values[1] * + (eigrp_metric_t)metric.bandwidth) / + (256 - metric.load)); if (eigrp->k_values[2]) - composite += (eigrp->k_values[2] * metric.delay); + composite += ((eigrp_metric_t)eigrp->k_values[2] * + (eigrp_metric_t)metric.delay); if (eigrp->k_values[3] && !eigrp->k_values[4]) - composite *= eigrp->k_values[3]; + composite *= (eigrp_metric_t)eigrp->k_values[3]; if (!eigrp->k_values[3] && eigrp->k_values[4]) - composite *= (eigrp->k_values[4] / metric.reliability); + composite *= ((eigrp_metric_t)eigrp->k_values[4] / + (eigrp_metric_t)metric.reliability); if (eigrp->k_values[3] && eigrp->k_values[4]) - composite *= ((eigrp->k_values[4] / metric.reliability) - + eigrp->k_values[3]); + composite *= (((eigrp_metric_t)eigrp->k_values[4] / + (eigrp_metric_t)metric.reliability) + + (eigrp_metric_t)eigrp->k_values[3]); composite = (composite <= EIGRP_METRIC_MAX) ? composite : EIGRP_METRIC_MAX; |