examples/vm_power_manager: fix string overflow
PATCH 1/1 examples/vm_power_manager: fix string overflow
Use strlcpy instead of strcpy to fix string overflow.
Coverity issue: 337671
Fixes a63504a90f ("examples/power: add JSON string handling")
Signed-off-by Reshma Pattan <[email protected]>
--- examples/vm_power_manager/channel_monitor.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
examples/vm_power_manager/channel_monitor.c +2 -1
@@ -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 );
Signature · 1 line
2.17.1
Quoted 17 lines · Reshma Pattan
Use strlcpy instead of strcpy to fix string overflow.
Coverity issue: 337671
Fixes a63504a90f ("examples/power: add JSON string handling")Signed-off-by Reshma Pattan <[email protected]>--- examples/vm_power_manager/channel_monitor.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)examples/vm_power_manager/channel_monitor.c +0
-0
examples/vm_power_manager/channel_monitor.c parse_json_to_pkt(json_t *element, struct channel_packet *pkt) · line 166
Quoted 9 lines
examples/vm_power_manager/channel_monitor.c +2
-1@@ -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 );
Acked-by David Hunt <[email protected]>
Thomas Monjalon
Applied15/04/2019 16:45, Hunt, David:
Quoted 11 lines · Reshma Pattan
Quoted 8 lines
Use strlcpy instead of strcpy to fix string overflow.
Coverity issue: 337671
Fixes a63504a90f ("examples/power: add JSON string handling")Signed-off-by Reshma Pattan <[email protected]>Acked-by David Hunt <[email protected]>
Applied, thanks