#include <rte_log.h>
#include <rte_malloc.h>
#include <rte_byteorder.h>
+#include <rte_string_fns.h>
#include "vhost_scsi.h"
#include "scsi_spec.h"
break;
case SPC_VPD_UNIT_SERIAL_NUMBER:
hlen = 4;
- strncpy((char *)vpage->params, bdev->name, 32);
+ strlcpy((char *)vpage->params, bdev->name,
+ sizeof(vpage->params));
vpage->alloc_len = rte_cpu_to_be_16(32);
break;
case SPC_VPD_DEVICE_IDENTIFICATION:
desig->piv = 1;
desig->reserved1 = 0;
desig->len = 8 + 16 + 32;
- strncpy((char *)desig->desig, "INTEL", 8);
+ strlcpy((char *)desig->desig, "INTEL", 8);
vhost_strcpy_pad((char *)&desig->desig[8],
bdev->product_name, 16, ' ');
- strncpy((char *)&desig->desig[24], bdev->name, 32);
+ strlcpy((char *)&desig->desig[24], bdev->name, 32);
len += sizeof(struct scsi_desig_desc) + 8 + 16 + 32;
buf += sizeof(struct scsi_desig_desc) + desig->len;
inqdata->flags3 = 0x2;
/* T10 VENDOR IDENTIFICATION */
- strncpy((char *)inqdata->t10_vendor_id, "INTEL", 8);
+ strlcpy((char *)inqdata->t10_vendor_id, "INTEL",
+ sizeof(inqdata->t10_vendor_id));
/* PRODUCT IDENTIFICATION */
snprintf((char *)inqdata->product_id,
bdev->product_name);
/* PRODUCT REVISION LEVEL */
- strncpy((char *)inqdata->product_rev, "0001", 4);
+ strlcpy((char *)inqdata->product_rev, "0001",
+ sizeof(inqdata->product_rev));
/* Standard inquiry data ends here. Only populate
* remaining fields if alloc_len indicates enough