From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id CE6495F3C for ; Wed, 3 Oct 2018 14:47:30 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Oct 2018 05:47:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,336,1534834800"; d="scan'208";a="78363204" Received: from yexl-server.sh.intel.com ([10.67.110.207]) by orsmga008.jf.intel.com with ESMTP; 03 Oct 2018 05:47:26 -0700 From: Xiaolong Ye To: dev@dpdk.org, Maxime Coquelin , Tiwei Bie , Zhihong Wang Cc: xiao.w.wang@intel.com, Rami Rosen , Wang Haiyue , Xiaolong Ye Date: Thu, 4 Oct 2018 03:34:39 +0800 Message-Id: <20181003193439.108373-1-xiaolong.ye@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <32f53ad0-92f4-4415-7a05-eff0c6fa779d@redhat.com> References: <32f53ad0-92f4-4415-7a05-eff0c6fa779d@redhat.com> Subject: [dpdk-dev] [PATCH] examples/vdpa: replace strncpy with strscpy function 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: Wed, 03 Oct 2018 12:47:31 -0000 rte_strscpy is safer to use. Signed-off-by: Xiaolong Ye --- examples/vdpa/main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/vdpa/main.c b/examples/vdpa/main.c index f96fa88b7..c5e8f58ec 100644 --- a/examples/vdpa/main.c +++ b/examples/vdpa/main.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -73,7 +74,7 @@ parse_args(int argc, char **argv) case 0: if (strncmp(long_option[idx].name, "iface", MAX_PATH_LEN) == 0) { - strncpy(iface, optarg, MAX_PATH_LEN); + rte_strscpy(iface, optarg, MAX_PATH_LEN); printf("iface %s\n", iface); } if (!strcmp(long_option[idx].name, "interactive")) { @@ -325,7 +326,7 @@ static void cmd_create_vdpa_port_parsed(void *parsed_result, struct cmd_create_result *res = parsed_result; struct rte_vdpa_dev_addr addr; - strncpy(vports[devcnt].ifname, res->socket_path, MAX_PATH_LEN); + rte_strscpy(vports[devcnt].ifname, res->socket_path, MAX_PATH_LEN); if (rte_pci_addr_parse(res->bdf, &addr.pci_addr) != 0) { cmdline_printf(cl, "Unable to parse the given bdf.\n"); return; -- 2.17.1