examples/power: fix string overflow
authorReshma Pattan <reshma.pattan@intel.com>
Wed, 10 Apr 2019 14:54:31 +0000 (15:54 +0100)
committerThomas Monjalon <thomas@monjalon.net>
Mon, 22 Apr 2019 22:15:10 +0000 (00:15 +0200)
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>
examples/vm_power_manager/channel_monitor.c

index bc5679d..971e4f2 100644 (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);