acl: fix cli tag parsing 12/30612/3
authorBenoît Ganne <bganne@cisco.com>
Tue, 5 Jan 2021 16:47:59 +0000 (17:47 +0100)
committerAndrew Yourtchenko <ayourtch@gmail.com>
Wed, 6 Jan 2021 16:36:03 +0000 (16:36 +0000)
 - tag is expected to be 64-bytes
 - when specifying tag on cli, a vector is allocated. Make sure it is
   freed

Type: fix

Change-Id: Id1741fe406819ca9f71edb081d4483f52cae547d
Signed-off-by: Benoît Ganne <bganne@cisco.com>
src/plugins/acl/acl.c

index 35f8b8c..7cde5ce 100644 (file)
@@ -2828,7 +2828,7 @@ acl_set_aclplugin_acl_fn (vlib_main_t * vm,
   u32 tcpflags, tcpmask;
   u32 src_prefix_length = 0, dst_prefix_length = 0;
   ip46_address_t src, dst;
-  u8 *tag = (u8 *) "cli";
+  u8 *tag = 0;
 
   if (!unformat_user (input, unformat_line_input, line_input))
     return 0;
@@ -2934,10 +2934,14 @@ acl_set_aclplugin_acl_fn (vlib_main_t * vm,
     }
 
   u32 acl_index = ~0;
+  if (!tag)
+    vec_add (tag, "cli", 4);
+  vec_validate (tag, STRUCT_SIZE_OF (acl_list_t, tag) - 1);
 
   rv = acl_add_list (vec_len (rules), rules, &acl_index, tag);
 
   vec_free (rules);
+  vec_free (tag);
 
   if (rv)
     return (clib_error_return (0, "failed"));