scsi: target: consistently null-terminate t10_wwn strings
In preparation for supporting user provided vendor strings, add an extra byte to the vendor, model and revision arrays in struct t10_wwn. This ensures that the full INQUIRY data can be carried in the arrays along with a null-terminator. Change a number of array readers and writers so that they account for explicit null-termination: - The pscsi_set_inquiry_info() and emulate_model_alias_store() codepaths don't currently explicitly null-terminate; fix this. - Existing t10_wwn field dumps use for-loops which step over null-terminators for right-padding. + Use printf with width specifiers instead. Signed-off-by: David Disseldorp <ddiss@suse.de> Reviewed-by: Roman Bolshakov <r.bolshakov@yadro.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
committed by
Martin K. Petersen
parent
0de263577d
commit
b2da4abf26
@@ -46,6 +46,10 @@
|
||||
/* Used by transport_get_inquiry_vpd_device_ident() */
|
||||
#define INQUIRY_VPD_DEVICE_IDENTIFIER_LEN 254
|
||||
|
||||
#define INQUIRY_VENDOR_LEN 8
|
||||
#define INQUIRY_MODEL_LEN 16
|
||||
#define INQUIRY_REVISION_LEN 4
|
||||
|
||||
/* Attempts before moving from SHORT to LONG */
|
||||
#define PYX_TRANSPORT_WINDOW_CLOSED_THRESHOLD 3
|
||||
#define PYX_TRANSPORT_WINDOW_CLOSED_WAIT_SHORT 3 /* In milliseconds */
|
||||
@@ -315,9 +319,13 @@ struct t10_vpd {
|
||||
};
|
||||
|
||||
struct t10_wwn {
|
||||
char vendor[8];
|
||||
char model[16];
|
||||
char revision[4];
|
||||
/*
|
||||
* SCSI left aligned strings may not be null terminated. +1 to ensure a
|
||||
* null terminator is always present.
|
||||
*/
|
||||
char vendor[INQUIRY_VENDOR_LEN + 1];
|
||||
char model[INQUIRY_MODEL_LEN + 1];
|
||||
char revision[INQUIRY_REVISION_LEN + 1];
|
||||
char unit_serial[INQUIRY_VPD_SERIAL_LEN];
|
||||
spinlock_t t10_vpd_lock;
|
||||
struct se_device *t10_dev;
|
||||
|
||||
Reference in New Issue
Block a user