[4/4] net/softnic: fix string copy
Checks
Commit Message
From: Reshma Pattan <reshma.pattan@intel.com>
Use strlcpy instead of strcpy to avoid buffer overrun.
Coverity issue: 323478
Fixes: b767f8efc8 ("net/softnic: replace pointers with arrays")
CC: cristian.dumitrescu@intel.com
CC: jasvinder.singh@intel.com
Signed-off-by: Reshma Pattan <reshma.pattan@intel.com>
---
drivers/net/softnic/rte_eth_softnic_cli.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
@@ -1867,7 +1867,7 @@ cmd_pipeline_port_in(struct pmd_internals *softnic,
p.type = PORT_IN_RXQ;
- strcpy(p.dev_name, tokens[t0 + 1]);
+ strlcpy(p.dev_name, tokens[t0 + 1], sizeof(p.dev_name));
if (strcmp(tokens[t0 + 2], "rxq") != 0) {
snprintf(out, out_size, MSG_ARG_NOT_FOUND, "rxq");
@@ -1890,7 +1890,7 @@ cmd_pipeline_port_in(struct pmd_internals *softnic,
p.type = PORT_IN_SWQ;
- strcpy(p.dev_name, tokens[t0 + 1]);
+ strlcpy(p.dev_name, tokens[t0 + 1], sizeof(p.dev_name));
t0 += 2;
} else if (strcmp(tokens[t0], "tmgr") == 0) {
@@ -1902,7 +1902,7 @@ cmd_pipeline_port_in(struct pmd_internals *softnic,
p.type = PORT_IN_TMGR;
- strcpy(p.dev_name, tokens[t0 + 1]);
+ strlcpy(p.dev_name, tokens[t0 + 1], sizeof(p.dev_name));
t0 += 2;
} else if (strcmp(tokens[t0], "tap") == 0) {
@@ -1914,7 +1914,7 @@ cmd_pipeline_port_in(struct pmd_internals *softnic,
p.type = PORT_IN_TAP;
- strcpy(p.dev_name, tokens[t0 + 1]);
+ strlcpy(p.dev_name, tokens[t0 + 1], sizeof(p.dev_name));
if (strcmp(tokens[t0 + 2], "mempool") != 0) {
snprintf(out, out_size, MSG_ARG_NOT_FOUND,
@@ -2009,7 +2009,8 @@ cmd_pipeline_port_in(struct pmd_internals *softnic,
return;
}
- strcpy(p.action_profile_name, tokens[t0 + 1]);
+ strlcpy(p.action_profile_name, tokens[t0 + 1],
+ sizeof(p.action_profile_name));
t0 += 2;
}