test/distributor: replace sprintf with strlcpy
authorPallantla Poornima <pallantlax.poornima@intel.com>
Thu, 14 Feb 2019 09:45:49 +0000 (09:45 +0000)
committerThomas Monjalon <thomas@monjalon.net>
Fri, 5 Apr 2019 08:40:56 +0000 (10:40 +0200)
sprintf function is not secure as it doesn't check the length of string.
replaced sprintf with strlcpy.

Fixes: f74df2c57e ("test/distributor: test single and burst API")
Cc: stable@dpdk.org
Signed-off-by: Pallantla Poornima <pallantlax.poornima@intel.com>
Acked-by: David Hunt <david.hunt@intel.com>
app/test/test_distributor.c

index 98919ec..da3348f 100644 (file)
@@ -11,6 +11,7 @@
 #include <rte_mempool.h>
 #include <rte_mbuf.h>
 #include <rte_distributor.h>
+#include <rte_string_fns.h>
 
 #define ITER_POWER 20 /* log 2 of how many iterations we do when timing. */
 #define BURST 32
@@ -642,9 +643,11 @@ test_distributor(void)
 
                worker_params.dist = dist[i];
                if (i)
-                       sprintf(worker_params.name, "burst");
+                       strlcpy(worker_params.name, "burst",
+                                       sizeof(worker_params.name));
                else
-                       sprintf(worker_params.name, "single");
+                       strlcpy(worker_params.name, "single",
+                                       sizeof(worker_params.name));
 
                rte_eal_mp_remote_launch(handle_work,
                                &worker_params, SKIP_MASTER);