From 81270cab1daea40a39a77c06b47b45e211631186 Mon Sep 17 00:00:00 2001 From: Long Wu Date: Thu, 8 Sep 2022 01:59:50 -0400 Subject: Fix name-array out-of-memory MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit "struct prox_port_cfg" "names" buffer size is 64 and it will lead to out-of-memory when do "snprintf" operation. Modify code to enlarge buffer size to 128. Fixes: 9a1e1e9336b3 ("Added support for multiple vlans in ipv4 vdev mode") Cc: xavier.simonart@intel.com Signed-off-by: Long Wu Reviewed-by: Simon Horman Reviewed-by: Chaoyong He Reviewed-by: Niklas Söderlund Change-Id: Iafbde578688e1a59f4b6e655e45b2d2951f36162 --- VNFs/DPPD-PROX/prox_port_cfg.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'VNFs/DPPD-PROX/prox_port_cfg.c') diff --git a/VNFs/DPPD-PROX/prox_port_cfg.c b/VNFs/DPPD-PROX/prox_port_cfg.c index add05a5e..bf7c4cb7 100644 --- a/VNFs/DPPD-PROX/prox_port_cfg.c +++ b/VNFs/DPPD-PROX/prox_port_cfg.c @@ -227,10 +227,10 @@ void init_rte_dev(int use_dummy_devices) } if (port_cfg->vdev[0]) { - char name[MAX_NAME_SIZE], tap[MAX_NAME_SIZE]; + char name[MAX_NAME_BUFFER_SIZE], tap[MAX_NAME_SIZE]; snprintf(tap, MAX_NAME_SIZE, "net_tap%d", port_id); #if (RTE_VERSION > RTE_VERSION_NUM(17,5,0,1)) - snprintf(name, MAX_NAME_SIZE, "iface=%s", port_cfg->vdev); + snprintf(name, MAX_NAME_BUFFER_SIZE, "iface=%s", port_cfg->vdev); rc = rte_vdev_init(tap, name); #else PROX_PANIC(1, "vdev not supported in DPDK < 17.05\n"); @@ -248,7 +248,7 @@ void init_rte_dev(int use_dummy_devices) for (uint32_t tag_id = 0; tag_id < prox_port_cfg[port_id].n_vlans; tag_id++) { prox_port_cfg[vdev_port_id].vlan_tags[tag_id] = prox_port_cfg[port_id].vlan_tags[tag_id]; char command[1024]; - snprintf(prox_port_cfg[vdev_port_id].names[tag_id], MAX_NAME_SIZE, "%s_%d", port_cfg->vdev, prox_port_cfg[port_id].vlan_tags[tag_id]); + snprintf(prox_port_cfg[vdev_port_id].names[tag_id], MAX_NAME_BUFFER_SIZE, "%s_%d", port_cfg->vdev, prox_port_cfg[port_id].vlan_tags[tag_id]); sprintf(command, "ip link add link %s name %s type vlan id %d", port_cfg->vdev, prox_port_cfg[vdev_port_id].names[tag_id], prox_port_cfg[port_id].vlan_tags[tag_id]); system(command); plog_info("\tRunning %s\n", command); -- cgit 1.2.3-korg