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 80372A0096 for ; Wed, 10 Apr 2019 16:54:48 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5D6171B1F3; Wed, 10 Apr 2019 16:54:47 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 55ACF1B1F1; Wed, 10 Apr 2019 16:54:46 +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 fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Apr 2019 07:54:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,332,1549958400"; d="scan'208";a="130197494" Received: from silpixa00400214.ir.intel.com (HELO silpixa00400214.ger.corp.intel.com) ([10.237.223.195]) by orsmga007.jf.intel.com with ESMTP; 10 Apr 2019 07:54:43 -0700 From: Reshma Pattan To: dev@dpdk.org Cc: Reshma Pattan , david.hunt@intel.com, stable@dpdk.org Date: Wed, 10 Apr 2019 15:54:31 +0100 Message-Id: <20190410145431.35269-1-reshma.pattan@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH] examples/vm_power_manager: fix string overflow 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: <20190410145431.OxMT9sQRwY4Cpe5T3D8fVQUvCrKaqbAroaR5uMn45b0@z> Use strlcpy instead of strcpy to fix string overflow. Coverity issue: 337671 Fixes: a63504a90f ("examples/power: add JSON string handling") CC: david.hunt@intel.com CC: stable@dpdk.org Signed-off-by: Reshma Pattan --- examples/vm_power_manager/channel_monitor.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/vm_power_manager/channel_monitor.c b/examples/vm_power_manager/channel_monitor.c index 74df0fe20..0b44a74b5 100644 --- a/examples/vm_power_manager/channel_monitor.c +++ b/examples/vm_power_manager/channel_monitor.c @@ -159,7 +159,8 @@ parse_json_to_pkt(json_t *element, struct channel_packet *pkt) if (ret) return ret; } else if (!strcmp(key, "name")) { - strcpy(pkt->vm_name, json_string_value(value)); + strlcpy(pkt->vm_name, json_string_value(value), + sizeof(pkt->vm_name)); } else if (!strcmp(key, "command")) { char command[32]; strlcpy(command, json_string_value(value), 32); -- 2.17.1