VPP-189: fix coverity issue in api_format.c 76/2976/3
authorFilip Tehlar <ftehlar@cisco.com>
Tue, 20 Sep 2016 10:37:09 +0000 (12:37 +0200)
committerDamjan Marion <dmarion.lists@gmail.com>
Tue, 20 Sep 2016 14:34:20 +0000 (14:34 +0000)
Change-Id: Ib16fd69abe93c1afb2ee1d38144763f57888585c
Signed-off-by: Filip Tehlar <ftehlar@cisco.com>
vpp-api-test/vat/api_format.c
vpp/vpp-api/api.c

index 1fbe924..7b5b434 100644 (file)
@@ -12963,6 +12963,12 @@ api_lisp_locator_dump (vat_main_t * vam)
       return -99;
     }
 
+  if (vec_len (ls_name) > 63)
+    {
+      errmsg ("error: locator set name too long!");
+      return -99;
+    }
+
   if (!vam->json_output)
     {
       fformat (vam->ofp, "%=16s%=16s%=16s\n", "locator", "priority",
@@ -12977,7 +12983,7 @@ api_lisp_locator_dump (vat_main_t * vam)
   else
     {
       vec_add1 (ls_name, 0);
-      strcpy ((char *) mp->ls_name, (char *) ls_name);
+      strncpy ((char *) mp->ls_name, (char *) ls_name, sizeof (mp->ls_name));
     }
 
   /* send it... */
index 62dd000..6630960 100644 (file)
@@ -5716,6 +5716,8 @@ vl_api_lisp_locator_dump_t_handler (vl_api_lisp_locator_dump_t * mp)
     ls_index = htonl (mp->ls_index);
   else
     {
+      /* make sure we get a proper C-string */
+      mp->ls_name[sizeof (mp->ls_name) - 1] = 0;
       ls_name = format (0, "%s", mp->ls_name);
       p = hash_get_mem (lcm->locator_set_index_by_name, ls_name);
       if (!p)