From b65421db4e5ec6d4efb1bad650ff5a11ae112fe8 Mon Sep 17 00:00:00 2001 From: David Hunt Date: Fri, 26 Apr 2019 15:04:54 +0100 Subject: [PATCH] examples/power: fix json null termination [ upstream commit 8f8f876bd76f9ea996f0e80f32137aa9c2c2071a ] coverity complains about a null-termination after a read, so we terminate once we exit the do-while read loop. Coverity issue: 337680 Fixes: a63504a90f ("examples/power: add JSON string handling") Signed-off-by: David Hunt Reviewed-by: Anatoly Burakov --- examples/vm_power_manager/channel_monitor.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/examples/vm_power_manager/channel_monitor.c b/examples/vm_power_manager/channel_monitor.c index 954bdf7874..b5b7c67877 100644 --- a/examples/vm_power_manager/channel_monitor.c +++ b/examples/vm_power_manager/channel_monitor.c @@ -842,12 +842,7 @@ read_json_packet(struct channel_info *chan_info) break; } while (indent > 0); - if (indent > 0) - /* - * We've broken out of the read loop without getting - * a closing brace, so throw away the data - */ - json_data[idx] = 0; + json_data[idx] = '\0'; if (strlen(json_data) == 0) continue;