zebra: don't overrun afi/safi array boundaries
zebra was not checking afi/safi values. This was leading to crashes where
these values were coming directly from some protocol's on-wire fields.
Safeguarding them in zebra is a good start.
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c
index a75d721..4dd8551 100644
--- a/zebra/zebra_rib.c
+++ b/zebra/zebra_rib.c
@@ -155,6 +155,9 @@
if (! vrf)
return NULL;
+ if( afi >= AFI_MAX || safi >= SAFI_MAX )
+ return NULL;
+
return vrf->table[afi][safi];
}
@@ -168,6 +171,9 @@
if (! vrf)
return NULL;
+ if( afi >= AFI_MAX || safi >= SAFI_MAX )
+ return NULL;
+
return vrf->stable[afi][safi];
}