From: Anoob Joseph Date: Mon, 12 Nov 2018 18:14:12 +0000 (+0000) Subject: crypto/octeontx: fix non null terminated device name X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=acbaf3cedcc783966f1187949a426996bb9072f1;p=dpdk.git crypto/octeontx: fix non null terminated device name 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. Coverity Issue: 323492 Fixes: 0dc1cffa4d33 ("crypto/octeontx: add hardware init routine") Signed-off-by: Ankur Dwivedi Signed-off-by: Anoob Joseph --- diff --git a/drivers/crypto/octeontx/otx_cryptodev_hw_access.c b/drivers/crypto/octeontx/otx_cryptodev_hw_access.c index 5e705a8313..18f2e6b154 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 #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) /* Bar0 base address */ cptvf->reg_base = reg_base; - strncpy(cptvf->dev_name, name, 32); + + /* Save device name */ + strlcpy(cptvf->dev_name, name, (sizeof(cptvf->dev_name))); cptvf->pdev = pdev;