From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id CE7901B613; Fri, 26 Apr 2019 13:24:31 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Apr 2019 04:24:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,397,1549958400"; d="scan'208";a="145935445" Received: from silpixa00399952.ir.intel.com (HELO silpixa00399952.ger.corp.intel.com) ([10.237.223.64]) by orsmga003.jf.intel.com with ESMTP; 26 Apr 2019 04:24:29 -0700 From: David Hunt To: dev@dpdk.org Cc: david.hunt@intel.com, stable@dpdk.org Date: Fri, 26 Apr 2019 12:24:22 +0100 Message-Id: <20190426112422.15719-1-david.hunt@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190426084337.3921-1-david.hunt@intel.com> References: <20190426084337.3921-1-david.hunt@intel.com> Subject: [dpdk-dev] [PATCH v2] examples/vm_power_manager: fix string null termination X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 Apr 2019 11:24:32 -0000 coverity complains about a null-termination after a read, so we terminate after exiting the do-while loop. The position is conditional 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 --- v2: * Move null termination outside of do-while. --- examples/vm_power_manager/channel_monitor.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/vm_power_manager/channel_monitor.c b/examples/vm_power_manager/channel_monitor.c index 971e4f2bc..03fdcd15a 100644 --- a/examples/vm_power_manager/channel_monitor.c +++ b/examples/vm_power_manager/channel_monitor.c @@ -822,6 +822,8 @@ read_json_packet(struct channel_info *chan_info) break; } while (indent > 0); + json_data[idx + (idx < MAX_JSON_STRING_LEN - 1)] = '\0'; + if (indent > 0) /* * We've broken out of the read loop without getting -- 2.17.1 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id C9092A05D3 for ; Fri, 26 Apr 2019 13:24:34 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1BDFD1B617; Fri, 26 Apr 2019 13:24:33 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id CE7901B613; Fri, 26 Apr 2019 13:24:31 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Apr 2019 04:24:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,397,1549958400"; d="scan'208";a="145935445" Received: from silpixa00399952.ir.intel.com (HELO silpixa00399952.ger.corp.intel.com) ([10.237.223.64]) by orsmga003.jf.intel.com with ESMTP; 26 Apr 2019 04:24:29 -0700 From: David Hunt To: dev@dpdk.org Cc: david.hunt@intel.com, stable@dpdk.org Date: Fri, 26 Apr 2019 12:24:22 +0100 Message-Id: <20190426112422.15719-1-david.hunt@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190426084337.3921-1-david.hunt@intel.com> References: <20190426084337.3921-1-david.hunt@intel.com> Subject: [dpdk-dev] [PATCH v2] examples/vm_power_manager: fix string null termination X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Content-Type: text/plain; charset="UTF-8" Message-ID: <20190426112422.tfMyF4lDVy3evPGf9q8IwgEfAUSgawgCWRQoRATGq6k@z> coverity complains about a null-termination after a read, so we terminate after exiting the do-while loop. The position is conditional 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 --- v2: * Move null termination outside of do-while. --- examples/vm_power_manager/channel_monitor.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/vm_power_manager/channel_monitor.c b/examples/vm_power_manager/channel_monitor.c index 971e4f2bc..03fdcd15a 100644 --- a/examples/vm_power_manager/channel_monitor.c +++ b/examples/vm_power_manager/channel_monitor.c @@ -822,6 +822,8 @@ read_json_packet(struct channel_info *chan_info) break; } while (indent > 0); + json_data[idx + (idx < MAX_JSON_STRING_LEN - 1)] = '\0'; + if (indent > 0) /* * We've broken out of the read loop without getting -- 2.17.1