diff options
author | jimharris <jimharris@FreeBSD.org> | 2013-07-17 23:23:38 +0000 |
---|---|---|
committer | jimharris <jimharris@FreeBSD.org> | 2013-07-17 23:23:38 +0000 |
commit | 8281445679a1a40c3039155ced18766cc7635428 (patch) | |
tree | 127037d85ff2ed1959c788208e14e5ece1cd7fbb /sys/dev/nvd/nvd.c | |
parent | 6ded7d8bc2691570cfdd7fc32187f20214d14279 (diff) | |
download | FreeBSD-src-8281445679a1a40c3039155ced18766cc7635428.zip FreeBSD-src-8281445679a1a40c3039155ced18766cc7635428.tar.gz |
Define constants for the lengths of the serial number, model number
and firmware revision in the controller's identify structure.
Also modify consumers of these fields to ensure they only use the
specified number of bytes for their respective fields.
Sponsored by: Intel
Reviewed by: carl
MFC after: 3 days
Diffstat (limited to 'sys/dev/nvd/nvd.c')
-rw-r--r-- | sys/dev/nvd/nvd.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/sys/dev/nvd/nvd.c b/sys/dev/nvd/nvd.c index 1d2d891..868a238 100644 --- a/sys/dev/nvd/nvd.c +++ b/sys/dev/nvd/nvd.c @@ -306,12 +306,16 @@ nvd_new_disk(struct nvme_namespace *ns, void *ctrlr_arg) disk->d_flags |= DISKFLAG_UNMAPPED_BIO; #endif + /* + * d_ident and d_descr are both far bigger than the length of either + * the serial or model number strings. + */ strlcpy(disk->d_ident, nvme_ns_get_serial_number(ns), - sizeof(disk->d_ident)); + min(sizeof(disk->d_ident), NVME_SERIAL_NUMBER_LENGTH)); #if __FreeBSD_version >= 900034 strlcpy(disk->d_descr, nvme_ns_get_model_number(ns), - sizeof(disk->d_descr)); + min(sizeof(disk->d_descr), NVME_MODEL_NUMBER_LENGTH)); #endif disk_create(disk, DISK_VERSION); |