Skip to content

Commit c3408c4

Browse files
committed
scsi: qla2xxx: Avoid possible run-time warning with long model_num
The prior strlcpy() replacement of strncpy() here (which was later replaced with strscpy()) expected pinfo->model_num (and pinfo->model_description) to be NUL-terminated, but it is possible it was not, as the code pattern here shows vha->hw->model_number (and vha->hw->model_desc) being exactly 1 character larger, and the replaced strncpy() was copying only up to the size of the source character array. Replace this with memtostr(), which is the unambiguous way to convert a maybe not-NUL-terminated character array into a NUL-terminated string. Fixes: 527e9b7 ("scsi: qla2xxx: Use memcpy() and strlcpy() instead of strcpy() and strncpy()") Reviewed-by: Martin K. Petersen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Kees Cook <[email protected]>
1 parent d430924 commit c3408c4

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

drivers/scsi/qla2xxx/qla_mr.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1909,10 +1909,8 @@ qlafx00_fx_disc(scsi_qla_host_t *vha, fc_port_t *fcport, uint16_t fx_type)
19091909
if (fx_type == FXDISC_GET_CONFIG_INFO) {
19101910
struct config_info_data *pinfo =
19111911
(struct config_info_data *) fdisc->u.fxiocb.rsp_addr;
1912-
strscpy(vha->hw->model_number, pinfo->model_num,
1913-
ARRAY_SIZE(vha->hw->model_number));
1914-
strscpy(vha->hw->model_desc, pinfo->model_description,
1915-
ARRAY_SIZE(vha->hw->model_desc));
1912+
memtostr(vha->hw->model_number, pinfo->model_num);
1913+
memtostr(vha->hw->model_desc, pinfo->model_description);
19161914
memcpy(&vha->hw->mr.symbolic_name, pinfo->symbolic_name,
19171915
sizeof(vha->hw->mr.symbolic_name));
19181916
memcpy(&vha->hw->mr.serial_num, pinfo->serial_num,

0 commit comments

Comments
 (0)