Re: [PATCH 5/8] target_core: simplify scsi_name_len calculation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2013-12-17 at 09:18 +0100, Hannes Reinecke wrote:
> scsi_name_len in spc_emulate_evpd_83 is calculated twice, with
> the results of the first calculation discarded. So remove it.
> And check for the maximum allowed length, too.
> 
> Signed-off-by: Hannes Reinecke <hare@xxxxxxx>
> ---
>  drivers/target/target_core_spc.c | 13 +++----------
>  1 file changed, 3 insertions(+), 10 deletions(-)
> 

Applied to for-next.

--nab

> diff --git a/drivers/target/target_core_spc.c b/drivers/target/target_core_spc.c
> index 021c3f4..603c411 100644
> --- a/drivers/target/target_core_spc.c
> +++ b/drivers/target/target_core_spc.c
> @@ -365,16 +365,6 @@ check_lu_gp:
>  		 * section 7.5.1 Table 362
>  		 */
>  check_scsi_name:
> -		scsi_name_len = strlen(tpg->se_tpg_tfo->tpg_get_wwn(tpg));
> -		/* UTF-8 ",t,0x<16-bit TPGT>" + NULL Terminator */
> -		scsi_name_len += 10;
> -		/* Check for 4-byte padding */
> -		padding = ((-scsi_name_len) & 3);
> -		if (padding != 0)
> -			scsi_name_len += padding;
> -		/* Header size + Designation descriptor */
> -		scsi_name_len += 4;
> -
>  		buf[off] =
>  			(tpg->se_tpg_tfo->get_fabric_proto_ident(tpg) << 4);
>  		buf[off++] |= 0x3; /* CODE SET == UTF-8 */
> @@ -402,8 +392,11 @@ check_scsi_name:
>  		 * shall be no larger than 256 and shall be a multiple
>  		 * of four.
>  		 */
> +		padding = ((-scsi_name_len) & 3);
>  		if (padding)
>  			scsi_name_len += padding;
> +		if (scsi_name_len > 256)
> +			scsi_name_len = 256;
>  
>  		buf[off-1] = scsi_name_len;
>  		off += scsi_name_len;


--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux