]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Nest: Fix crash in rta_show() for RPKI and Babel routes
authorOndrej Zajicek (work) <santiago@crfreenet.org>
Mon, 5 Nov 2018 12:56:59 +0000 (13:56 +0100)
committerOndrej Zajicek (work) <santiago@crfreenet.org>
Mon, 5 Nov 2018 12:56:59 +0000 (13:56 +0100)
Some new route source values did not have associated string
in rta_show(), which might caused crash in some cases.

nest/route.h
nest/rt-attr.c

index 2ec1dc7fa3158465930058bc134fb7ac49e20ac6..e19e11ca72adf3f31b42fd67b68724d93db45e4d 100644 (file)
@@ -421,6 +421,7 @@ typedef struct rta {
 #define RTS_PIPE 12                    /* Inter-table wormhole */
 #define RTS_BABEL 13                   /* Babel route */
 #define RTS_RPKI 14                    /* Route Origin Authorization */
+#define RTS_MAX 15
 
 
 #define RTC_UNICAST 0
index 73ca47486dc28703de69847bbda336d441ba0c70..7a91a4f6267c830ae51d107953500707b24b3b7a 100644 (file)
 
 #include <stddef.h>
 
+const char * const rta_src_names[RTS_MAX] = {
+  [RTS_DUMMY]          = "",
+  [RTS_STATIC]         = "static",
+  [RTS_INHERIT]                = "inherit",
+  [RTS_DEVICE]         = "device",
+  [RTS_STATIC_DEVICE]  = "static-device",
+  [RTS_REDIRECT]       = "redirect",
+  [RTS_RIP]            = "RIP",
+  [RTS_OSPF]           = "OSPF",
+  [RTS_OSPF_IA]                = "OSPF-IA",
+  [RTS_OSPF_EXT1]      = "OSPF-E1",
+  [RTS_OSPF_EXT2]      = "OSPF-E2",
+  [RTS_BGP]            = "BGP",
+  [RTS_PIPE]           = "pipe",
+  [RTS_BABEL]          = "Babel",
+  [RTS_RPKI]           = "RPKI",
+};
+
 const char * rta_dest_names[RTD_MAX] = {
   [RTD_NONE]           = "",
   [RTD_UNICAST]                = "unicast",
@@ -1262,10 +1280,7 @@ rta_dump_all(void)
 void
 rta_show(struct cli *c, rta *a)
 {
-  static char *src_names[] = { "dummy", "static", "inherit", "device", "static-device", "redirect",
-                              "RIP", "OSPF", "OSPF-IA", "OSPF-E1", "OSPF-E2", "BGP", "pipe" };
-
-  cli_printf(c, -1008, "\tType: %s %s", src_names[a->source], ip_scope_text(a->scope));
+  cli_printf(c, -1008, "\tType: %s %s", rta_src_names[a->source], ip_scope_text(a->scope));
 
   for(ea_list *eal = a->eattrs; eal; eal=eal->next)
     for(int i=0; i<eal->count; i++)