DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH v1] examples/vm_power_manager: fix string null termination
@ 2019-04-26  8:43 David Hunt
  2019-04-26  8:43 ` David Hunt
                   ` (2 more replies)
  0 siblings, 3 replies; 20+ messages in thread
From: David Hunt @ 2019-04-26  8:43 UTC (permalink / raw)
  To: dev; +Cc: david.hunt, stable

coverity complains about a null-termination after a read,
so we terminate conditionally on whether idx is within
the buffer or at the end of the buffer.

Coverity issue: 337680
Fixes: a63504a90f ("examples/power: add JSON string handling")
CC: stable@dpdk.org
Signed-off-by: David Hunt <david.hunt@intel.com>
---
 examples/vm_power_manager/channel_monitor.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/examples/vm_power_manager/channel_monitor.c b/examples/vm_power_manager/channel_monitor.c
index 971e4f2bc..711722fef 100644
--- a/examples/vm_power_manager/channel_monitor.c
+++ b/examples/vm_power_manager/channel_monitor.c
@@ -808,6 +808,7 @@ read_json_packet(struct channel_info *chan_info)
 		int indent = 0;
 		do {
 			n_bytes = read(chan_info->fd, &json_data[idx], 1);
+			json_data[idx + (idx < MAX_JSON_STRING_LEN - 1)] = '\0';
 			if (n_bytes == 0)
 				break;
 			if (json_data[idx] == '{')
-- 
2.17.1

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2019-05-02 23:43 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-26  8:43 [dpdk-dev] [PATCH v1] examples/vm_power_manager: fix string null termination David Hunt
2019-04-26  8:43 ` David Hunt
2019-04-26 10:33 ` Burakov, Anatoly
2019-04-26 10:33   ` Burakov, Anatoly
2019-04-26 11:16   ` Hunt, David
2019-04-26 11:16     ` Hunt, David
2019-04-26 11:24 ` [dpdk-dev] [PATCH v2] " David Hunt
2019-04-26 11:24   ` David Hunt
2019-04-26 11:56   ` Burakov, Anatoly
2019-04-26 11:56     ` Burakov, Anatoly
2019-04-26 12:31     ` Bruce Richardson
2019-04-26 12:31       ` Bruce Richardson
2019-04-26 12:47       ` Burakov, Anatoly
2019-04-26 12:47         ` Burakov, Anatoly
2019-04-26 14:04   ` [dpdk-dev] [PATCH v3] " David Hunt
2019-04-26 14:04     ` David Hunt
2019-04-26 14:10     ` Burakov, Anatoly
2019-04-26 14:10       ` Burakov, Anatoly
2019-05-02 23:43       ` Thomas Monjalon
2019-05-02 23:43         ` Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).