From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 1B1CE7EC7; Fri, 26 Apr 2019 10:43:48 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Apr 2019 01:43:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,396,1549958400"; d="scan'208";a="146003269" Received: from silpixa00399952.ir.intel.com (HELO silpixa00399952.ger.corp.intel.com) ([10.237.223.64]) by fmsmga007.fm.intel.com with ESMTP; 26 Apr 2019 01:43:43 -0700 From: David Hunt To: dev@dpdk.org Cc: david.hunt@intel.com, stable@dpdk.org Date: Fri, 26 Apr 2019 09:43:37 +0100 Message-Id: <20190426084337.3921-1-david.hunt@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH v1] 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 08:43:49 -0000 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 --- 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 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 8A0FAA05D3 for ; Fri, 26 Apr 2019 10:43:50 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5DF4E1B1EA; Fri, 26 Apr 2019 10:43:50 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 1B1CE7EC7; Fri, 26 Apr 2019 10:43:48 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Apr 2019 01:43:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,396,1549958400"; d="scan'208";a="146003269" Received: from silpixa00399952.ir.intel.com (HELO silpixa00399952.ger.corp.intel.com) ([10.237.223.64]) by fmsmga007.fm.intel.com with ESMTP; 26 Apr 2019 01:43:43 -0700 From: David Hunt To: dev@dpdk.org Cc: david.hunt@intel.com, stable@dpdk.org Date: Fri, 26 Apr 2019 09:43:37 +0100 Message-Id: <20190426084337.3921-1-david.hunt@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH v1] 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: <20190426084337.kgXufpEaJpZPf3mZsGdjBegnuDmtDQgte3wHKXFeRBI@z> 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 --- 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