From mboxrd@z Thu Jan 1 00:00:00 1970 From: Anoob Joseph Subject: [PATCH 1/3] crypto/octeontx: fix non null terminated string Date: Sun, 11 Nov 2018 15:24:36 +0000 Message-ID: <1541949837-9629-2-git-send-email-anoob.joseph@caviumnetworks.com> References: <1541949837-9629-1-git-send-email-anoob.joseph@caviumnetworks.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Cc: "Joseph, Anoob" , "Jacob, Jerin" , "Athreya, Narayana Prasad" , "Dwivedi, Ankur" , "dev@dpdk.org" To: Akhil Goyal , Pablo de Lara Return-path: Received: from NAM03-BY2-obe.outbound.protection.outlook.com (mail-eopbgr780083.outbound.protection.outlook.com [40.107.78.83]) by dpdk.org (Postfix) with ESMTP id 7ECE2548B for ; Sun, 11 Nov 2018 16:24:37 +0100 (CET) In-Reply-To: <1541949837-9629-1-git-send-email-anoob.joseph@caviumnetworks.com> Content-Language: en-US List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" If the length of string pointed by 'name' is equal to or greater than the sizeof cptvf->dev_name string, the resultant string will not be null terminated. Using strlcpy would make sure the string would always be null terminated. Fixes: 0dc1cffa4d33 ("crypto/octeontx: add hardware init routine") Signed-off-by: Ankur Dwivedi Signed-off-by: Anoob Joseph --- drivers/crypto/octeontx/otx_cryptodev_hw_access.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/crypto/octeontx/otx_cryptodev_hw_access.c b/drivers/cr= ypto/octeontx/otx_cryptodev_hw_access.c index 5e705a8..18f2e6b 100644 --- a/drivers/crypto/octeontx/otx_cryptodev_hw_access.c +++ b/drivers/crypto/octeontx/otx_cryptodev_hw_access.c @@ -9,6 +9,7 @@ #include #include #include +#include =20 #include "otx_cryptodev_hw_access.h" #include "otx_cryptodev_mbox.h" @@ -366,7 +367,9 @@ otx_cpt_hw_init(struct cpt_vf *cptvf, void *pdev, void = *reg_base, char *name) =20 /* Bar0 base address */ cptvf->reg_base =3D reg_base; - strncpy(cptvf->dev_name, name, 32); + + /* Save device name */ + strlcpy(cptvf->dev_name, name, (sizeof(cptvf->dev_name))); =20 cptvf->pdev =3D pdev; =20 --=20 2.7.4