Skip to content

Commit

Permalink
examples/power: fix json null termination
Browse files Browse the repository at this point in the history
[ upstream commit 8f8f876 ]

coverity complains about a null-termination after a read,
so we terminate once we exit the do-while read loop.

Coverity issue: 337680
Fixes: a63504a ("examples/power: add JSON string handling")

Signed-off-by: David Hunt <david.hunt@intel.com>
Reviewed-by: Anatoly Burakov <anatoly.burakov@intel.com>
  • Loading branch information
climberhunt authored and kevintraynor committed May 8, 2019
1 parent 695d45d commit b65421d
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions examples/vm_power_manager/channel_monitor.c
Expand Up @@ -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;
Expand Down

0 comments on commit b65421d

Please sign in to comment.