vhost: fix sprintf with snprintf
authorPallantla Poornima <pallantlax.poornima@intel.com>
Mon, 4 Feb 2019 07:28:06 +0000 (07:28 +0000)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 22 Feb 2019 13:39:49 +0000 (14:39 +0100)
sprintf function is not secure as it doesn't check the length of string.
More secure function snprintf is used.

Fixes: d7280c9fffcb ("vhost: support selective datapath")
Cc: stable@dpdk.org
Signed-off-by: Pallantla Poornima <pallantlax.poornima@intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Acked-by: Tiwei Bie <tiwei.bie@intel.com>
lib/librte_vhost/vdpa.c

index 1ff9b00..321e11f 100644 (file)
@@ -66,7 +66,7 @@ rte_vdpa_register_device(struct rte_vdpa_dev_addr *addr,
        if (i == MAX_VHOST_DEVICE)
                return -1;
 
-       sprintf(device_name, "vdpa-dev-%d", i);
+       snprintf(device_name, sizeof(device_name), "vdpa-dev-%d", i);
        dev = rte_zmalloc(device_name, sizeof(struct rte_vdpa_device),
                        RTE_CACHE_LINE_SIZE);
        if (!dev)