From patchwork Fri Apr 26 14:04:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hunt, David" X-Patchwork-Id: 53101 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id EAF631B6A1; Fri, 26 Apr 2019 16:05:06 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id 310871B114; Fri, 26 Apr 2019 16:05:04 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Apr 2019 07:05:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,397,1549958400"; d="scan'208";a="168195188" Received: from silpixa00399952.ir.intel.com (HELO silpixa00399952.ger.corp.intel.com) ([10.237.223.64]) by fmsmga001.fm.intel.com with ESMTP; 26 Apr 2019 07:05:02 -0700 From: David Hunt To: dev@dpdk.org Cc: david.hunt@intel.com, stable@dpdk.org Date: Fri, 26 Apr 2019 15:04:54 +0100 Message-Id: <20190426140454.29684-1-david.hunt@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190426112422.15719-1-david.hunt@intel.com> References: <20190426112422.15719-1-david.hunt@intel.com> Subject: [dpdk-dev] [PATCH v3] 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" 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") CC: stable@dpdk.org Signed-off-by: David Hunt Reviewed-by: Anatoly Burakov --- v2: Move null termination outside of do-while. v3: Simplify null termimation --- 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 971e4f2bc..4a287109b 100644 --- a/examples/vm_power_manager/channel_monitor.c +++ b/examples/vm_power_manager/channel_monitor.c @@ -822,12 +822,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;