From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3EF07C43219 for ; Fri, 26 Apr 2019 14:05:09 +0000 (UTC) Received: from dpdk.org (dpdk.org [92.243.14.124]) by mail.kernel.org (Postfix) with ESMTP id EFB202077B for ; Fri, 26 Apr 2019 14:05:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EFB202077B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dev-bounces@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 --- 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; -- 2.17.1