|
@@ -34,7 +34,6 @@ struct scsi_dev_info_list_table {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
-static const char spaces[] = " "; /* 16 of them */
|
|
|
|
|
static blist_flags_t scsi_default_dev_flags;
|
|
static blist_flags_t scsi_default_dev_flags;
|
|
|
static LIST_HEAD(scsi_dev_info_list);
|
|
static LIST_HEAD(scsi_dev_info_list);
|
|
|
static char scsi_dev_flags[256];
|
|
static char scsi_dev_flags[256];
|
|
@@ -298,20 +297,13 @@ static void scsi_strcpy_devinfo(char *name, char *to, size_t to_length,
|
|
|
size_t from_length;
|
|
size_t from_length;
|
|
|
|
|
|
|
|
from_length = strlen(from);
|
|
from_length = strlen(from);
|
|
|
- strncpy(to, from, min(to_length, from_length));
|
|
|
|
|
- if (from_length < to_length) {
|
|
|
|
|
- if (compatible) {
|
|
|
|
|
- /*
|
|
|
|
|
- * NUL terminate the string if it is short.
|
|
|
|
|
- */
|
|
|
|
|
- to[from_length] = '\0';
|
|
|
|
|
- } else {
|
|
|
|
|
- /*
|
|
|
|
|
- * space pad the string if it is short.
|
|
|
|
|
- */
|
|
|
|
|
- strncpy(&to[from_length], spaces,
|
|
|
|
|
- to_length - from_length);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ /* This zero-pads the destination */
|
|
|
|
|
+ strncpy(to, from, to_length);
|
|
|
|
|
+ if (from_length < to_length && !compatible) {
|
|
|
|
|
+ /*
|
|
|
|
|
+ * space pad the string if it is short.
|
|
|
|
|
+ */
|
|
|
|
|
+ memset(&to[from_length], ' ', to_length - from_length);
|
|
|
}
|
|
}
|
|
|
if (from_length > to_length)
|
|
if (from_length > to_length)
|
|
|
printk(KERN_WARNING "%s: %s string '%s' is too long\n",
|
|
printk(KERN_WARNING "%s: %s string '%s' is too long\n",
|
|
@@ -458,7 +450,8 @@ static struct scsi_dev_info_list *scsi_dev_info_list_find(const char *vendor,
|
|
|
/*
|
|
/*
|
|
|
* vendor strings must be an exact match
|
|
* vendor strings must be an exact match
|
|
|
*/
|
|
*/
|
|
|
- if (vmax != strlen(devinfo->vendor) ||
|
|
|
|
|
|
|
+ if (vmax != strnlen(devinfo->vendor,
|
|
|
|
|
+ sizeof(devinfo->vendor)) ||
|
|
|
memcmp(devinfo->vendor, vskip, vmax))
|
|
memcmp(devinfo->vendor, vskip, vmax))
|
|
|
continue;
|
|
continue;
|
|
|
|
|
|
|
@@ -466,7 +459,7 @@ static struct scsi_dev_info_list *scsi_dev_info_list_find(const char *vendor,
|
|
|
* @model specifies the full string, and
|
|
* @model specifies the full string, and
|
|
|
* must be larger or equal to devinfo->model
|
|
* must be larger or equal to devinfo->model
|
|
|
*/
|
|
*/
|
|
|
- mlen = strlen(devinfo->model);
|
|
|
|
|
|
|
+ mlen = strnlen(devinfo->model, sizeof(devinfo->model));
|
|
|
if (mmax < mlen || memcmp(devinfo->model, mskip, mlen))
|
|
if (mmax < mlen || memcmp(devinfo->model, mskip, mlen))
|
|
|
continue;
|
|
continue;
|
|
|
return devinfo;
|
|
return devinfo;
|