summaryrefslogtreecommitdiff
path: root/examples/vhost_scsi
diff options
context:
space:
mode:
authorJacek Piasecki <jacekx.piasecki@intel.com>2017-10-25 12:07:18 +0200
committerThomas Monjalon <thomas@monjalon.net>2017-10-25 12:16:51 +0200
commit681459bf9cd5778ada011e6d8d681436ec5394f0 (patch)
tree7035c4840552fa465ddf3c194390d6fe20f39efe /examples/vhost_scsi
parent1e02d735c1446705592ca8d89b4b500f9492a8ef (diff)
downloaddpdk-681459bf9cd5778ada011e6d8d681436ec5394f0.zip
dpdk-681459bf9cd5778ada011e6d8d681436ec5394f0.tar.gz
dpdk-681459bf9cd5778ada011e6d8d681436ec5394f0.tar.xz
examples/vhost_scsi: fix product id string termination
Use snprintf instead strncpy to get safe null string termination. There was possible to get not terminated string after strncpy operation. Coverity issue: 158631 Fixes: db75c7af19bb ("examples/vhost_scsi: introduce a new sample app") Cc: stable@dpdk.org Signed-off-by: Jacek Piasecki <jacekx.piasecki@intel.com> Acked-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Diffstat (limited to 'examples/vhost_scsi')
-rw-r--r--examples/vhost_scsi/scsi.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/examples/vhost_scsi/scsi.c b/examples/vhost_scsi/scsi.c
index 54d3104..fd430ec 100644
--- a/examples/vhost_scsi/scsi.c
+++ b/examples/vhost_scsi/scsi.c
@@ -307,7 +307,9 @@ vhost_bdev_scsi_inquiry_command(struct vhost_block_dev *bdev,
strncpy((char *)inqdata->t10_vendor_id, "INTEL", 8);
/* PRODUCT IDENTIFICATION */
- strncpy((char *)inqdata->product_id, bdev->product_name, 16);
+ snprintf((char *)inqdata->product_id,
+ RTE_DIM(inqdata->product_id), "%s",
+ bdev->product_name);
/* PRODUCT REVISION LEVEL */
strncpy((char *)inqdata->product_rev, "0001", 4);