From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id AE3501B577; Fri, 22 Mar 2019 08:53:24 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Mar 2019 00:53:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,256,1549958400"; d="scan'208";a="127637516" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga008.jf.intel.com with ESMTP; 22 Mar 2019 00:53:21 -0700 Received: from wgcvswdev001.ir.intel.com (wgcvswdev001.ir.intel.com [10.102.246.100]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id x2M7rK0w031682; Fri, 22 Mar 2019 07:53:20 GMT Received: from wgcvswdev001.ir.intel.com (localhost [127.0.0.1]) by wgcvswdev001.ir.intel.com with ESMTP id x2M7qeNc003628; Fri, 22 Mar 2019 07:52:40 GMT Received: (from tchaitax@localhost) by wgcvswdev001.ir.intel.com with œ id x2M7qeTp003624; Fri, 22 Mar 2019 07:52:40 GMT From: Chaitanya Babu Talluri To: dev@dpdk.org Cc: reshma.pattan@intel.com, jananeex.m.parthasarathy@intel.com, rmody@marvell.com, shshaikh@marvell.com, beilei.xing@intel.com, qi.z.zhang@intel.com, Chaitanya Babu Talluri , stable@dpdk.org Date: Fri, 22 Mar 2019 07:51:42 +0000 Message-Id: <1553241102-3265-1-git-send-email-tallurix.chaitanya.babu@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: <1552912870-3526-1-git-send-email-tallurix.chaitanya.babu@intel.com> References: <1552912870-3526-1-git-send-email-tallurix.chaitanya.babu@intel.com> Subject: [dpdk-dev] [PATCH v8] drivers/net: fix possible overflow using strlcat 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, 22 Mar 2019 07:53:25 -0000 strcat does not check the destination length and there might be chances of string overflow so instead of strcat, strlcat is used. Fixes: 540a211084 ("bnx2x: driver core") Fixes: e163c18a15 ("net/i40e: update ptype and pctype info") Cc: stable@dpdk.org Signed-off-by: Chaitanya Babu Talluri --- v8: Added missing semi-colon. v7: Corrected title. v6: Updated title. v5: Removed strcat. v4: Corrected usage of strlcat. v3: Instead of strncat, used strlcat. v2: Instead of strncat, used snprintf. --- drivers/net/bnx2x/bnx2x.c | 5 +++-- drivers/net/i40e/i40e_ethdev.c | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/net/bnx2x/bnx2x.c b/drivers/net/bnx2x/bnx2x.c index 26b3828e8..ab092e23f 100644 --- a/drivers/net/bnx2x/bnx2x.c +++ b/drivers/net/bnx2x/bnx2x.c @@ -25,6 +25,7 @@ #include #include #include +#include #define BNX2X_PMD_VER_PREFIX "BNX2X PMD" #define BNX2X_PMD_VERSION_MAJOR 1 @@ -11741,13 +11742,13 @@ static const char *get_bnx2x_flags(uint32_t flags) for (i = 0; i < 5; i++) if (flags & (1 << i)) { - strcat(flag_str, flag[i]); + strlcat(flag_str, flag[i], sizeof(flag_str)); flags ^= (1 << i); } if (flags) { static char unknown[BNX2X_INFO_STR_MAX]; snprintf(unknown, 32, "Unknown flag mask %x", flags); - strcat(flag_str, unknown); + strlcat(flag_str, unknown, sizeof(flag_str)); } return flag_str; } diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index dca61f03a..9bc9a4390 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -12201,8 +12201,8 @@ i40e_update_customized_pctype(struct rte_eth_dev *dev, uint8_t *pkg, for (n = 0; n < proto_num; n++) { if (proto[n].proto_id != proto_id) continue; - strcat(name, proto[n].name); - strcat(name, "_"); + strlcat(name, proto[n].name, sizeof(name)); + strlcat(name, "_", sizeof(name)); break; } } -- 2.17.2 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 71A96A00E6 for ; Fri, 22 Mar 2019 08:53:29 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6C8D01B57D; Fri, 22 Mar 2019 08:53:27 +0100 (CET) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id AE3501B577; Fri, 22 Mar 2019 08:53:24 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Mar 2019 00:53:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,256,1549958400"; d="scan'208";a="127637516" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga008.jf.intel.com with ESMTP; 22 Mar 2019 00:53:21 -0700 Received: from wgcvswdev001.ir.intel.com (wgcvswdev001.ir.intel.com [10.102.246.100]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id x2M7rK0w031682; Fri, 22 Mar 2019 07:53:20 GMT Received: from wgcvswdev001.ir.intel.com (localhost [127.0.0.1]) by wgcvswdev001.ir.intel.com with ESMTP id x2M7qeNc003628; Fri, 22 Mar 2019 07:52:40 GMT Received: (from tchaitax@localhost) by wgcvswdev001.ir.intel.com with œ id x2M7qeTp003624; Fri, 22 Mar 2019 07:52:40 GMT From: Chaitanya Babu Talluri To: dev@dpdk.org Cc: reshma.pattan@intel.com, jananeex.m.parthasarathy@intel.com, rmody@marvell.com, shshaikh@marvell.com, beilei.xing@intel.com, qi.z.zhang@intel.com, Chaitanya Babu Talluri , stable@dpdk.org Date: Fri, 22 Mar 2019 07:51:42 +0000 Message-Id: <1553241102-3265-1-git-send-email-tallurix.chaitanya.babu@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: <1552912870-3526-1-git-send-email-tallurix.chaitanya.babu@intel.com> References: <1552912870-3526-1-git-send-email-tallurix.chaitanya.babu@intel.com> Subject: [dpdk-dev] [PATCH v8] drivers/net: fix possible overflow using strlcat 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: <20190322075142.Upi_HVyeS2CEE39t2xipdSH87toOh0n-qGSqy24r3as@z> strcat does not check the destination length and there might be chances of string overflow so instead of strcat, strlcat is used. Fixes: 540a211084 ("bnx2x: driver core") Fixes: e163c18a15 ("net/i40e: update ptype and pctype info") Cc: stable@dpdk.org Signed-off-by: Chaitanya Babu Talluri --- v8: Added missing semi-colon. v7: Corrected title. v6: Updated title. v5: Removed strcat. v4: Corrected usage of strlcat. v3: Instead of strncat, used strlcat. v2: Instead of strncat, used snprintf. --- drivers/net/bnx2x/bnx2x.c | 5 +++-- drivers/net/i40e/i40e_ethdev.c | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/net/bnx2x/bnx2x.c b/drivers/net/bnx2x/bnx2x.c index 26b3828e8..ab092e23f 100644 --- a/drivers/net/bnx2x/bnx2x.c +++ b/drivers/net/bnx2x/bnx2x.c @@ -25,6 +25,7 @@ #include #include #include +#include #define BNX2X_PMD_VER_PREFIX "BNX2X PMD" #define BNX2X_PMD_VERSION_MAJOR 1 @@ -11741,13 +11742,13 @@ static const char *get_bnx2x_flags(uint32_t flags) for (i = 0; i < 5; i++) if (flags & (1 << i)) { - strcat(flag_str, flag[i]); + strlcat(flag_str, flag[i], sizeof(flag_str)); flags ^= (1 << i); } if (flags) { static char unknown[BNX2X_INFO_STR_MAX]; snprintf(unknown, 32, "Unknown flag mask %x", flags); - strcat(flag_str, unknown); + strlcat(flag_str, unknown, sizeof(flag_str)); } return flag_str; } diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index dca61f03a..9bc9a4390 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -12201,8 +12201,8 @@ i40e_update_customized_pctype(struct rte_eth_dev *dev, uint8_t *pkg, for (n = 0; n < proto_num; n++) { if (proto[n].proto_id != proto_id) continue; - strcat(name, proto[n].name); - strcat(name, "_"); + strlcat(name, proto[n].name, sizeof(name)); + strlcat(name, "_", sizeof(name)); break; } } -- 2.17.2