Hello,

I am proposing a fix for a segfault encountered in bird6, in the
nexthop_compare_node function.

This patch adds checks for validating that x->iface and y->iface are not
null before accessing their index field.

I initially proposed a fix on calico's bird fork :
https://github.com/projectcalico/bird/pull/117 but I was asked to propose
it to the official repo.

Please find the full patch attached.
Best regards,

Mathieu.
From e66d69d4fa9cb10362c5f4ba7e7d3c1cd4005973 Mon Sep 17 00:00:00 2001
From: Mathieu <[email protected]>
Date: Mon, 16 Feb 2026 14:25:14 +0100
Subject: [PATCH] Add null checks for iface before accessing index in
 mpnh_compare_node

---
 nest/rt-attr.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/nest/rt-attr.c b/nest/rt-attr.c
index e10e1ecb..1fb93f8e 100644
--- a/nest/rt-attr.c
+++ b/nest/rt-attr.c
@@ -255,6 +255,12 @@ nexthop_compare_node(const struct nexthop *x, const struct nexthop *y)
       return r;
   }
 
+  if (!x->iface)
+    return 1;
+
+  if (!y->iface)
+    return -1;
+
   return ((int) x->iface->index) - ((int) y->iface->index);
 }
 
-- 
2.34.1

Reply via email to