summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuentin Young <qlyoung@cumulusnetworks.com>2020-01-04 01:25:38 +0100
committerQuentin Young <qlyoung@cumulusnetworks.com>2020-01-04 01:25:38 +0100
commite33d7b6a0365b7d1c5708dd4015ae662f64bc104 (patch)
tree5343d2701caeba90f4fa589553571377e7d90a91
parentMerge pull request #5611 from qlyoung/fix-bgp-no-listen-docstring (diff)
downloadfrr-e33d7b6a0365b7d1c5708dd4015ae662f64bc104.tar.xz
frr-e33d7b6a0365b7d1c5708dd4015ae662f64bc104.zip
lib: fix ifindex comparison overflow
Very small (negative!) ifindexes, when subtracted, can overflow. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
-rw-r--r--lib/if.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/if.c b/lib/if.c
index c91407084..7332dceb4 100644
--- a/lib/if.c
+++ b/lib/if.c
@@ -137,7 +137,12 @@ static int if_cmp_func(const struct interface *ifp1,
static int if_cmp_index_func(const struct interface *ifp1,
const struct interface *ifp2)
{
- return ifp1->ifindex - ifp2->ifindex;
+ if (ifp1->ifindex == ifp2->ifindex)
+ return 0;
+ else if (ifp1->ifindex > ifp2->ifindex)
+ return 1;
+ else
+ return -1;
}
static void ifp_connected_free(void *arg)