Browse Source

lib: vty_prefix_list_install should validate afi/safi

* lib/plist.c: (vty_prefix_list_install) Check afi/safi is supported and warn
  if not, as a safeguard and to ensure the user is warned, if somehow that
  code is ever called for non-IP AFI.
Paul Jakma 3 years ago
parent
commit
867946bb88
1 changed files with 10 additions and 1 deletions
  1. 10 1
      lib/plist.c

+ 10 - 1
lib/plist.c

@@ -675,7 +675,16 @@ vty_prefix_list_install (struct vty *vty, afi_t afi, const char *name,
   int seqnum = -1;
   int lenum = 0;
   int genum = 0;
-
+  
+  /* This code only works for IP.  Provide a safe-guard and user-visible
+   * warning
+   */
+  if (!(afi == AFI_IP || afi == AFI_IP6))
+    {
+      vty_out (vty, "%% prefix must be IPv4 or IPv6!%s", VTY_NEWLINE);
+      return CMD_WARNING;
+    }
+  
   /* Sequential number. */
   if (seq)
     seqnum = atoi (seq);