From 8d53e9f3c6001dcb2865f6e894da5b54e1418f88 Mon Sep 17 00:00:00 2001 From: Christian Ehrhardt Date: Thu, 4 Jul 2019 10:40:06 +0200 Subject: New upstream version 18.11.2 Change-Id: I23eb4f9179abf1f9c659891f8fddb27ee68ad26b Signed-off-by: Christian Ehrhardt --- examples/vm_power_manager/channel_monitor.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'examples/vm_power_manager/channel_monitor.c') diff --git a/examples/vm_power_manager/channel_monitor.c b/examples/vm_power_manager/channel_monitor.c index 5da53154..b5b7c678 100644 --- a/examples/vm_power_manager/channel_monitor.c +++ b/examples/vm_power_manager/channel_monitor.c @@ -158,7 +158,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]; snprintf(command, 32, "%s", json_string_value(value)); @@ -835,18 +836,13 @@ read_json_packet(struct channel_info *chan_info) indent--; if ((indent > 0) || (idx > 0)) idx++; - if (indent == 0) + if (indent <= 0) json_data[idx] = 0; if (idx >= MAX_JSON_STRING_LEN-1) 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; -- cgit 1.2.3-korg