From patchwork Tue Apr 9 16:00:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Pattan, Reshma" X-Patchwork-Id: 52489 X-Patchwork-Delegate: thomas@monjalon.net 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 C57984F93; Tue, 9 Apr 2019 18:00:31 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id 0EA3D2BCE; Tue, 9 Apr 2019 18:00:29 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Apr 2019 09:00:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,329,1549958400"; d="scan'208";a="129896031" Received: from silpixa00400214.ir.intel.com (HELO silpixa00400214.ger.corp.intel.com) ([10.237.223.195]) by orsmga007.jf.intel.com with ESMTP; 09 Apr 2019 09:00:26 -0700 From: Reshma Pattan To: dev@dpdk.org Cc: Reshma Pattan , david.hunt@intel.com, stable@dpdk.org Date: Tue, 9 Apr 2019 17:00:24 +0100 Message-Id: <20190409160024.40431-1-reshma.pattan@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH] 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" After the read() the jason_data null termination is missing for the case "indent < 0", for "indent > 0" and "indent == 0" cases null termination is already handled. So add the missing case "indent < 0" to the existing "indent == 0" case to fix null termination. Coverity issue: 337680 Fixes: a63504a90f ("examples/power: add JSON string handling") CC: david.hunt@intel.com CC: stable@dpdk.org Signed-off-by: Reshma Pattan Acked-by: David Hunt --- examples/vm_power_manager/channel_monitor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/vm_power_manager/channel_monitor.c b/examples/vm_power_manager/channel_monitor.c index 74df0fe20..c67ca4710 100644 --- a/examples/vm_power_manager/channel_monitor.c +++ b/examples/vm_power_manager/channel_monitor.c @@ -807,7 +807,7 @@ 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;