[dpdk-dev] [PATCH] examples/vm_power_manager: fix string overflow
Reshma Pattan
reshma.pattan at intel.com
Wed Apr 10 16:54:31 CEST 2019
Use strlcpy instead of strcpy to fix string overflow.
Coverity issue: 337671
Fixes: a63504a90f ("examples/power: add JSON string handling")
CC: david.hunt at intel.com
CC: stable at dpdk.org
Signed-off-by: Reshma Pattan <reshma.pattan at intel.com>
---
examples/vm_power_manager/channel_monitor.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/examples/vm_power_manager/channel_monitor.c b/examples/vm_power_manager/channel_monitor.c
index 74df0fe20..0b44a74b5 100644
--- a/examples/vm_power_manager/channel_monitor.c
+++ b/examples/vm_power_manager/channel_monitor.c
@@ -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);
--
2.17.1
More information about the dev
mailing list