> -----Original Message-----
> From: dev [mailto:dev-boun...@dpdk.org] On Behalf Of Michal Jastrzebski
> Sent: Friday, September 22, 2017 3:10 PM
> To: y...@fridaylinux.org; maxime.coque...@redhat.com
> Cc: dev@dpdk.org; Jain, Deepak K <deepak.k.j...@intel.com>; Piasecki,
> JacekX <jacekx.piase...@intel.com>; Liu, Changpeng
> <changpeng....@intel.com>; sta...@dpdk.org
> Subject: [dpdk-dev] [PATCH] examples/vhost_scsi: fix buffer not terminated
> 
> From: Jacek Piasecki <jacekx.piase...@intel.com>
> 
> Fix size of buffer in strcpy. There was possible to get
> not terminated string after copy operation.
> 
> Coverity issue: 158629
> Fixes: db75c7af19bb ("examples/vhost_scsi: introduce a new sample app")
> Cc: changpeng....@intel.com
> Cc: sta...@dpdk.org
> 
> Signed-off-by: Jacek Piasecki <jacekx.piase...@intel.com>
> ---
>  examples/vhost_scsi/vhost_scsi.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/examples/vhost_scsi/vhost_scsi.c
> b/examples/vhost_scsi/vhost_scsi.c
> index b4f1f8d..b1a8c93 100644
> --- a/examples/vhost_scsi/vhost_scsi.c
> +++ b/examples/vhost_scsi/vhost_scsi.c
> @@ -186,8 +186,9 @@ static uint64_t gpa_to_vva(int vid, uint64_t gpa)
>       if (!bdev)
>               return NULL;
> 
> -     strncpy(bdev->name, bdev_name, sizeof(bdev->name));
> -     strncpy(bdev->product_name, bdev_serial, sizeof(bdev-
> >product_name));
> +     strncpy(bdev->name, bdev_name, sizeof(bdev->name) - 1);
> +     strncpy(bdev->product_name, bdev_serial,
> +                     sizeof(bdev->product_name) - 1);
>       bdev->blocklen = blk_size;
>       bdev->blockcnt = blk_cnt;
>       bdev->write_cache = wce_enable;
> --
> 1.9.1

Hi Yu / Maxime,
I would like to ask for a feedback regarding proposed fix.
If everything is ok with it, please send acked-by.

Best regards
Michal.

Reply via email to