net/softnic: fix possible buffer overflow

sprintf function is not secure as it doesn't check the length of string.
More secure function snprintf is used.

Fixes: daabf2fb94 ("net/softnic: map flow action to table action")
Cc: stable@dpdk.org

Signed-off-by: Pallantla Poornima <pallantlax.poornima@intel.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
This commit is contained in:
Pallantla Poornima 2019-02-04 07:23:48 +00:00 committed by Ferruh Yigit
parent 6416a61843
commit fef6b21639

View File

@ -1283,7 +1283,8 @@ flow_rule_action_get(struct pmd_internals *softnic,
action, action,
"QUEUE: Invalid RX queue ID"); "QUEUE: Invalid RX queue ID");
sprintf(name, "RXQ%u", (uint32_t)conf->index); snprintf(name, sizeof(name), "RXQ%u",
(uint32_t)conf->index);
status = softnic_pipeline_port_out_find(softnic, status = softnic_pipeline_port_out_find(softnic,
pipeline->name, pipeline->name,
@ -1373,7 +1374,7 @@ flow_rule_action_get(struct pmd_internals *softnic,
action, action,
"RSS: Invalid RX queue ID"); "RSS: Invalid RX queue ID");
sprintf(name, "RXQ%u", snprintf(name, sizeof(name), "RXQ%u",
(uint32_t)conf->queue[i]); (uint32_t)conf->queue[i]);
status = softnic_pipeline_port_out_find(softnic, status = softnic_pipeline_port_out_find(softnic,