Re: [PATCH] scsi: qedf: Avoid reading past end of buffer

From: Bart Van Assche
Date: Fri May 05 2017 - 19:01:12 EST


On Fri, 2017-05-05 at 15:42 -0700, Kees Cook wrote:
> diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
> index cceddd995a4b..a5c97342fd5d 100644
> --- a/drivers/scsi/qedf/qedf_main.c
> +++ b/drivers/scsi/qedf/qedf_main.c
> @@ -2895,7 +2895,7 @@ static int __qedf_probe(struct pci_dev *pdev, int mode)
> slowpath_params.drv_minor = QEDF_DRIVER_MINOR_VER;
> slowpath_params.drv_rev = QEDF_DRIVER_REV_VER;
> slowpath_params.drv_eng = QEDF_DRIVER_ENG_VER;
> - memcpy(slowpath_params.name, "qedf", QED_DRV_VER_STR_SIZE);
> + strncpy(slowpath_params.name, "qedf", QED_DRV_VER_STR_SIZE);
> rc = qed_ops->common->slowpath_start(qedf->cdev, &slowpath_params);
> if (rc) {
> QEDF_ERR(&(qedf->dbg_ctx), "Cannot start slowpath.\n");

Hello Kees,

Although this patch looks fine to me, isn't strlcpy() preferred over strncpy()?

Bart.