From patchwork Fri Jul 12 14:04:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hunt, David" X-Patchwork-Id: 56408 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 99A6E1B9FA; Fri, 12 Jul 2019 16:05:02 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id BC6822C23; Fri, 12 Jul 2019 16:05:00 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Jul 2019 07:04:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,482,1557212400"; d="scan'208";a="365618695" Received: from silpixa00399952.ir.intel.com (HELO silpixa00399952.ger.corp.intel.com) ([10.237.222.88]) by fmsmga006.fm.intel.com with ESMTP; 12 Jul 2019 07:04:58 -0700 From: David Hunt To: dev@dpdk.org Cc: david.hunt@intel.com, stable@dpdk.org Date: Fri, 12 Jul 2019 15:04:02 +0100 Message-Id: <20190712140402.8492-1-david.hunt@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH v1] examples/vm_power: fix strcpy buffer overrun 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" replace strcpy with rte_strlcpy to prevent buffer overrun With fix, attempting to use a VERY lonng vm name results in a nicely truncated 32 character name rather than a segfault: Setting VM Name to [sdfdsfsfsdffdsdsasdsadasdakjshd] Cc: stable@dpdk.org Fixes: 59287933a0bb ("examples/vm_power: add options to guest app") Signed-off-by: David Hunt Acked-by: Anatoly Burakov Signed-off-by: David Hunt --- examples/vm_power_manager/guest_cli/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/vm_power_manager/guest_cli/main.c b/examples/vm_power_manager/guest_cli/main.c index 36365b124..a18eb214a 100644 --- a/examples/vm_power_manager/guest_cli/main.c +++ b/examples/vm_power_manager/guest_cli/main.c @@ -65,7 +65,7 @@ parse_args(int argc, char **argv) switch (opt) { /* portmask */ case 'n': - strcpy(policy->vm_name, optarg); + rte_strlcpy(policy->vm_name, optarg, VM_MAX_NAME_SZ); printf("Setting VM Name to [%s]\n", policy->vm_name); break; case 'b':