examples/power: fix string overflow

Use strlcpy instead of strcpy to fix string overflow.

Coverity issue: 337671
Fixes: a63504a90f ("examples/power: add JSON string handling")
Cc: stable@dpdk.org

Signed-off-by: Reshma Pattan <reshma.pattan@intel.com>
Acked-by: David Hunt <david.hunt@intel.com>
This commit is contained in:
Reshma Pattan 2019-04-10 15:54:31 +01:00 committed by Thomas Monjalon
parent 4c2caea070
commit 57fad3e25f

View File

@ -159,7 +159,8 @@ parse_json_to_pkt(json_t *element, struct channel_packet *pkt)
if (ret)
return ret;
} else if (!strcmp(key, "name")) {
strcpy(pkt->vm_name, json_string_value(value));
strlcpy(pkt->vm_name, json_string_value(value),
sizeof(pkt->vm_name));
} else if (!strcmp(key, "command")) {
char command[32];
strlcpy(command, json_string_value(value), 32);