]> git.proxmox.com Git - mirror_frr.git/commitdiff
bgpd: Fix off-by-one in `clear [ip] bgp...`
authorQuentin Young <qlyoung@cumulusnetworks.com>
Tue, 4 Oct 2016 00:22:15 +0000 (00:22 +0000)
committerQuentin Young <qlyoung@cumulusnetworks.com>
Tue, 4 Oct 2016 00:22:15 +0000 (00:22 +0000)
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
bgpd/bgp_vty.c

index 4f04a973476df0de19a91fe4dab46773cf46a70b..7dc877483506a00acf9b201e3e671556140f3351 100644 (file)
@@ -6064,19 +6064,23 @@ DEFUN (clear_ip_bgp_all,
   /* afi safi */
   idx_afi = idx_clr_sort + 1;
   idx_safi = idx_clr_sort + 2;
-  bgp_get_argv_afi_safi (argc, argv, idx_afi, idx_safi, &afi, &safi, &idx_soft_in_out);
-
-  /* soft, soft in, or soft out */
-  if (strmatch(argv[idx_soft_in_out]->text, "in"))
-    clr_type = BGP_CLEAR_SOFT_IN;
-  else if (strmatch(argv[idx_soft_in_out]->text, "out"))
-    clr_type = BGP_CLEAR_SOFT_OUT;
-  else if (strmatch(argv[idx_soft_in_out]->text, "soft"))
-    clr_type = BGP_CLEAR_SOFT_BOTH;
-  else if (strmatch(argv[idx_soft_in_out]->text, "prefix-filter"))
-    clr_type = BGP_CLEAR_SOFT_IN_ORF_PREFIX;
-  else
-    clr_type = BGP_CLEAR_SOFT_NONE;
+  idx_soft_in_out = 0;
+  if (argc > idx_afi)
+    bgp_get_argv_afi_safi (argc, argv, idx_afi, idx_safi, &afi, &safi, &idx_soft_in_out);
+
+  clr_type = BGP_CLEAR_SOFT_NONE;
+  if (idx_soft_in_out && argc > idx_soft_in_out)
+  {
+    /* soft, soft in, or soft out */
+    if (strmatch(argv[idx_soft_in_out]->text, "in"))
+      clr_type = BGP_CLEAR_SOFT_IN;
+    else if (strmatch(argv[idx_soft_in_out]->text, "out"))
+      clr_type = BGP_CLEAR_SOFT_OUT;
+    else if (strmatch(argv[idx_soft_in_out]->text, "soft"))
+      clr_type = BGP_CLEAR_SOFT_BOTH;
+    else if (strmatch(argv[idx_soft_in_out]->text, "prefix-filter"))
+      clr_type = BGP_CLEAR_SOFT_IN_ORF_PREFIX;
+  }
 
   return bgp_clear_vty (vty, vrf, afi, safi, clr_sort, clr_type, clr_arg);
 }