1
0
Fork 0
remarkable-linux/drivers/scsi/ibmvscsi
Breno Leitao 336b737541 scsi: ibmvscsi: Improve strings handling
[ Upstream commit 1262dc09dc ]

Currently an open firmware property is copied into partition_name variable
without keeping a room for \0.

Later one, this variable (partition_name), which is 97 bytes long, is
strncpyed into ibmvcsci_host_data->madapter_info->partition_name, which is
96 bytes long, possibly truncating it 'again' and removing the \0.

This patch simply decreases the partition name to 96 and just copy using
strlcpy() which guarantees that the string is \0 terminated. I think there
is no issue if this there is a truncation in this very first copy, i.e,
when the open firmware property is read and copied into the driver for the
very first time;

This issue also causes the following warning on GCC 8:

	drivers/scsi/ibmvscsi/ibmvscsi.c:281:2: warning:  strncpy  output may be truncated copying 96 bytes from a string of length 96 [-Wstringop-truncation]
	...
	inlined from  ibmvscsi_probe  at drivers/scsi/ibmvscsi/ibmvscsi.c:2221:7:
	drivers/scsi/ibmvscsi/ibmvscsi.c:265:3: warning:  strncpy  specified bound 97 equals destination size [-Wstringop-truncation]

CC: Bart Van Assche <bart.vanassche@wdc.com>
CC: Tyrel Datwyler <tyreld@linux.vnet.ibm.com>
Signed-off-by: Breno Leitao <leitao@debian.org>
Acked-by: Tyrel Datwyler <tyreld@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-10-03 17:00:49 -07:00
..
Makefile ibmvstgt: remove 2014-07-17 22:07:43 +02:00
ibmvfc.c scsi: ibmvfc: ibmvscsi: ibmvscsi_tgt: constify vio_device_id 2017-08-25 17:42:42 -04:00
ibmvfc.h scsi: ibmvfc: fix misdefined reserved field in ibmvfc_fcp_rsp_info 2018-02-28 10:19:38 +01:00
ibmvscsi.c scsi: ibmvscsi: Improve strings handling 2018-10-03 17:00:49 -07:00
ibmvscsi.h scsi: ibmvscsi: add vscsi hosts to global list_head 2016-12-08 17:02:01 -05:00