diff options
Diffstat (limited to 'drivers/scsi/scsi_devinfo.c')
| -rw-r--r-- | drivers/scsi/scsi_devinfo.c | 33 | 
1 files changed, 12 insertions, 21 deletions
diff --git a/drivers/scsi/scsi_devinfo.c b/drivers/scsi/scsi_devinfo.c index 78d4aa8df675..dfb8da83fa50 100644 --- a/drivers/scsi/scsi_devinfo.c +++ b/drivers/scsi/scsi_devinfo.c @@ -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 LIST_HEAD(scsi_dev_info_list);  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;  	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)  		 printk(KERN_WARNING "%s: %s string '%s' is too long\n", @@ -382,10 +374,8 @@ int scsi_dev_info_list_add_keyed(int compatible, char *vendor, char *model,  			    model, compatible);  	if (strflags) -		devinfo->flags = simple_strtoul(strflags, NULL, 0); -	else -		devinfo->flags = flags; - +		flags = (__force blist_flags_t)simple_strtoul(strflags, NULL, 0); +	devinfo->flags = flags;  	devinfo->compatible = compatible;  	if (compatible) @@ -458,7 +448,8 @@ static struct scsi_dev_info_list *scsi_dev_info_list_find(const char *vendor,  			/*  			 * 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))  				continue; @@ -466,7 +457,7 @@ static struct scsi_dev_info_list *scsi_dev_info_list_find(const char *vendor,  			 * @model specifies the full string, and  			 * 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))  				continue;  			return devinfo;  | 
