Commit eae0d1f6 authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Kleber Sacilotto de Souza

scsi: bfa: convert to strlcpy/strlcat

BugLink: https://bugs.launchpad.net/bugs/1811077

commit 8c5a50e8 upstream.

The bfa driver has a number of real issues with string termination
that gcc-8 now points out:

drivers/scsi/bfa/bfad_bsg.c: In function 'bfad_iocmd_port_get_attr':
drivers/scsi/bfa/bfad_bsg.c:320:9: error: argument to 'sizeof' in 'strncpy' call is the same expression as the source; did you mean to use the size of the destination? [-Werror=sizeof-pointer-memaccess]
drivers/scsi/bfa/bfa_fcs.c: In function 'bfa_fcs_fabric_psymb_init':
drivers/scsi/bfa/bfa_fcs.c:775:9: error: argument to 'sizeof' in 'strncat' call is the same expression as the source; did you mean to use the size of the destination? [-Werror=sizeof-pointer-memaccess]
drivers/scsi/bfa/bfa_fcs.c:781:9: error: argument to 'sizeof' in 'strncat' call is the same expression as the source; did you mean to use the size of the destination? [-Werror=sizeof-pointer-memaccess]
drivers/scsi/bfa/bfa_fcs.c:788:9: error: argument to 'sizeof' in 'strncat' call is the same expression as the source; did you mean to use the size of the destination? [-Werror=sizeof-pointer-memaccess]
drivers/scsi/bfa/bfa_fcs.c:801:10: error: argument to 'sizeof' in 'strncat' call is the same expression as the source; did you mean to use the size of the destination? [-Werror=sizeof-pointer-memaccess]
drivers/scsi/bfa/bfa_fcs.c:808:10: error: argument to 'sizeof' in 'strncat' call is the same expression as the source; did you mean to use the size of the destination? [-Werror=sizeof-pointer-memaccess]
drivers/scsi/bfa/bfa_fcs.c: In function 'bfa_fcs_fabric_nsymb_init':
drivers/scsi/bfa/bfa_fcs.c:837:10: error: argument to 'sizeof' in 'strncat' call is the same expression as the source; did you mean to use the size of the destination? [-Werror=sizeof-pointer-memaccess]
drivers/scsi/bfa/bfa_fcs.c:844:10: error: argument to 'sizeof' in 'strncat' call is the same expression as the source; did you mean to use the size of the destination? [-Werror=sizeof-pointer-memaccess]
drivers/scsi/bfa/bfa_fcs.c:852:10: error: argument to 'sizeof' in 'strncat' call is the same expression as the source; did you mean to use the size of the destination? [-Werror=sizeof-pointer-memaccess]
drivers/scsi/bfa/bfa_fcs.c: In function 'bfa_fcs_fabric_psymb_init':
drivers/scsi/bfa/bfa_fcs.c:778:2: error: 'strncat' output may be truncated copying 10 bytes from a string of length 63 [-Werror=stringop-truncation]
drivers/scsi/bfa/bfa_fcs.c:784:2: error: 'strncat' output may be truncated copying 30 bytes from a string of length 63 [-Werror=stringop-truncation]
drivers/scsi/bfa/bfa_fcs.c:803:3: error: 'strncat' output may be truncated copying 44 bytes from a string of length 63 [-Werror=stringop-truncation]
drivers/scsi/bfa/bfa_fcs.c:811:3: error: 'strncat' output may be truncated copying 16 bytes from a string of length 63 [-Werror=stringop-truncation]
drivers/scsi/bfa/bfa_fcs.c: In function 'bfa_fcs_fabric_nsymb_init':
drivers/scsi/bfa/bfa_fcs.c:840:2: error: 'strncat' output may be truncated copying 10 bytes from a string of length 63 [-Werror=stringop-truncation]
drivers/scsi/bfa/bfa_fcs.c:847:2: error: 'strncat' output may be truncated copying 30 bytes from a string of length 63 [-Werror=stringop-truncation]
drivers/scsi/bfa/bfa_fcs_lport.c: In function 'bfa_fcs_fdmi_get_hbaattr':
drivers/scsi/bfa/bfa_fcs_lport.c:2657:10: error: argument to 'sizeof' in 'strncat' call is the same expression as the source; did you mean to use the size of the destination? [-Werror=sizeof-pointer-memaccess]
drivers/scsi/bfa/bfa_fcs_lport.c:2659:11: error: argument to 'sizeof' in 'strncat' call is the same expression as the source; did you mean to use the size of the destination? [-Werror=sizeof-pointer-memaccess]
drivers/scsi/bfa/bfa_fcs_lport.c: In function 'bfa_fcs_lport_ms_gmal_response':
drivers/scsi/bfa/bfa_fcs_lport.c:3232:5: error: 'strncpy' output may be truncated copying 16 bytes from a string of length 247 [-Werror=stringop-truncation]
drivers/scsi/bfa/bfa_fcs_lport.c: In function 'bfa_fcs_lport_ns_send_rspn_id':
drivers/scsi/bfa/bfa_fcs_lport.c:4670:3: error: 'strncpy' output truncated before terminating nul copying as many bytes from a string as its length [-Werror=stringop-truncation]
drivers/scsi/bfa/bfa_fcs_lport.c:4682:3: error: 'strncat' output truncated before terminating nul copying as many bytes from a string as its length [-Werror=stringop-truncation]
drivers/scsi/bfa/bfa_fcs_lport.c: In function 'bfa_fcs_lport_ns_util_send_rspn_id':
drivers/scsi/bfa/bfa_fcs_lport.c:5206:3: error: 'strncpy' output truncated before terminating nul copying as many bytes from a string as its length [-Werror=stringop-truncation]
drivers/scsi/bfa/bfa_fcs_lport.c:5215:3: error: 'strncat' output truncated before terminating nul copying as many bytes from a string as its length [-Werror=stringop-truncation]
drivers/scsi/bfa/bfa_fcs_lport.c: In function 'bfa_fcs_fdmi_get_portattr':
drivers/scsi/bfa/bfa_fcs_lport.c:2751:2: error: 'strncpy' specified bound 128 equals destination size [-Werror=stringop-truncation]
drivers/scsi/bfa/bfa_fcbuild.c: In function 'fc_rspnid_build':
drivers/scsi/bfa/bfa_fcbuild.c:1254:2: error: 'strncpy' output truncated before terminating nul copying as many bytes from a string as its length [-Werror=stringop-truncation]
drivers/scsi/bfa/bfa_fcbuild.c:1253:25: note: length computed here
drivers/scsi/bfa/bfa_fcbuild.c: In function 'fc_rsnn_nn_build':
drivers/scsi/bfa/bfa_fcbuild.c:1275:2: error: 'strncpy' output truncated before terminating nul copying as many bytes from a string as its length [-Werror=stringop-truncation]

In most cases, this can be addressed by correctly calling strlcpy and
strlcat instead of strncpy/strncat, with the size of the destination
buffer as the last argument.

For consistency, I'm changing the other callers of strncpy() in this
driver the same way.
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Reviewed-by: default avatarJohannes Thumshirn <jthumshirn@suse.de>
Acked-by: default avatarSudarsana Kalluru <Sudarsana.Kalluru@cavium.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarJuerg Haefliger <juergh@canonical.com>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
parent f1051bff
...@@ -1249,8 +1249,8 @@ fc_rspnid_build(struct fchs_s *fchs, void *pyld, u32 s_id, u16 ox_id, ...@@ -1249,8 +1249,8 @@ fc_rspnid_build(struct fchs_s *fchs, void *pyld, u32 s_id, u16 ox_id,
memset(rspnid, 0, sizeof(struct fcgs_rspnid_req_s)); memset(rspnid, 0, sizeof(struct fcgs_rspnid_req_s));
rspnid->dap = s_id; rspnid->dap = s_id;
rspnid->spn_len = (u8) strlen((char *)name); strlcpy(rspnid->spn, name, sizeof(rspnid->spn));
strncpy((char *)rspnid->spn, (char *)name, rspnid->spn_len); rspnid->spn_len = (u8) strlen(rspnid->spn);
return sizeof(struct fcgs_rspnid_req_s) + sizeof(struct ct_hdr_s); return sizeof(struct fcgs_rspnid_req_s) + sizeof(struct ct_hdr_s);
} }
...@@ -1270,8 +1270,8 @@ fc_rsnn_nn_build(struct fchs_s *fchs, void *pyld, u32 s_id, ...@@ -1270,8 +1270,8 @@ fc_rsnn_nn_build(struct fchs_s *fchs, void *pyld, u32 s_id,
memset(rsnn_nn, 0, sizeof(struct fcgs_rsnn_nn_req_s)); memset(rsnn_nn, 0, sizeof(struct fcgs_rsnn_nn_req_s));
rsnn_nn->node_name = node_name; rsnn_nn->node_name = node_name;
rsnn_nn->snn_len = (u8) strlen((char *)name); strlcpy(rsnn_nn->snn, name, sizeof(rsnn_nn->snn));
strncpy((char *)rsnn_nn->snn, (char *)name, rsnn_nn->snn_len); rsnn_nn->snn_len = (u8) strlen(rsnn_nn->snn);
return sizeof(struct fcgs_rsnn_nn_req_s) + sizeof(struct ct_hdr_s); return sizeof(struct fcgs_rsnn_nn_req_s) + sizeof(struct ct_hdr_s);
} }
......
...@@ -831,23 +831,23 @@ bfa_fcs_fabric_psymb_init(struct bfa_fcs_fabric_s *fabric) ...@@ -831,23 +831,23 @@ bfa_fcs_fabric_psymb_init(struct bfa_fcs_fabric_s *fabric)
bfa_ioc_get_adapter_model(&fabric->fcs->bfa->ioc, model); bfa_ioc_get_adapter_model(&fabric->fcs->bfa->ioc, model);
/* Model name/number */ /* Model name/number */
strncpy((char *)&port_cfg->sym_name, model, strlcpy(port_cfg->sym_name.symname, model,
BFA_FCS_PORT_SYMBNAME_MODEL_SZ); BFA_SYMNAME_MAXLEN);
strncat((char *)&port_cfg->sym_name, BFA_FCS_PORT_SYMBNAME_SEPARATOR, strlcat(port_cfg->sym_name.symname, BFA_FCS_PORT_SYMBNAME_SEPARATOR,
sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR)); BFA_SYMNAME_MAXLEN);
/* Driver Version */ /* Driver Version */
strncat((char *)&port_cfg->sym_name, (char *)driver_info->version, strlcat(port_cfg->sym_name.symname, driver_info->version,
BFA_FCS_PORT_SYMBNAME_VERSION_SZ); BFA_SYMNAME_MAXLEN);
strncat((char *)&port_cfg->sym_name, BFA_FCS_PORT_SYMBNAME_SEPARATOR, strlcat(port_cfg->sym_name.symname, BFA_FCS_PORT_SYMBNAME_SEPARATOR,
sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR)); BFA_SYMNAME_MAXLEN);
/* Host machine name */ /* Host machine name */
strncat((char *)&port_cfg->sym_name, strlcat(port_cfg->sym_name.symname,
(char *)driver_info->host_machine_name, driver_info->host_machine_name,
BFA_FCS_PORT_SYMBNAME_MACHINENAME_SZ); BFA_SYMNAME_MAXLEN);
strncat((char *)&port_cfg->sym_name, BFA_FCS_PORT_SYMBNAME_SEPARATOR, strlcat(port_cfg->sym_name.symname, BFA_FCS_PORT_SYMBNAME_SEPARATOR,
sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR)); BFA_SYMNAME_MAXLEN);
/* /*
* Host OS Info : * Host OS Info :
...@@ -855,24 +855,24 @@ bfa_fcs_fabric_psymb_init(struct bfa_fcs_fabric_s *fabric) ...@@ -855,24 +855,24 @@ bfa_fcs_fabric_psymb_init(struct bfa_fcs_fabric_s *fabric)
* OS name string and instead copy the entire OS info string (64 bytes). * OS name string and instead copy the entire OS info string (64 bytes).
*/ */
if (driver_info->host_os_patch[0] == '\0') { if (driver_info->host_os_patch[0] == '\0') {
strncat((char *)&port_cfg->sym_name, strlcat(port_cfg->sym_name.symname,
(char *)driver_info->host_os_name, driver_info->host_os_name,
BFA_FCS_OS_STR_LEN); BFA_SYMNAME_MAXLEN);
strncat((char *)&port_cfg->sym_name, strlcat(port_cfg->sym_name.symname,
BFA_FCS_PORT_SYMBNAME_SEPARATOR, BFA_FCS_PORT_SYMBNAME_SEPARATOR,
sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR)); BFA_SYMNAME_MAXLEN);
} else { } else {
strncat((char *)&port_cfg->sym_name, strlcat(port_cfg->sym_name.symname,
(char *)driver_info->host_os_name, driver_info->host_os_name,
BFA_FCS_PORT_SYMBNAME_OSINFO_SZ); BFA_SYMNAME_MAXLEN);
strncat((char *)&port_cfg->sym_name, strlcat(port_cfg->sym_name.symname,
BFA_FCS_PORT_SYMBNAME_SEPARATOR, BFA_FCS_PORT_SYMBNAME_SEPARATOR,
sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR)); BFA_SYMNAME_MAXLEN);
/* Append host OS Patch Info */ /* Append host OS Patch Info */
strncat((char *)&port_cfg->sym_name, strlcat(port_cfg->sym_name.symname,
(char *)driver_info->host_os_patch, driver_info->host_os_patch,
BFA_FCS_PORT_SYMBNAME_OSPATCH_SZ); BFA_SYMNAME_MAXLEN);
} }
/* null terminate */ /* null terminate */
...@@ -892,26 +892,26 @@ bfa_fcs_fabric_nsymb_init(struct bfa_fcs_fabric_s *fabric) ...@@ -892,26 +892,26 @@ bfa_fcs_fabric_nsymb_init(struct bfa_fcs_fabric_s *fabric)
bfa_ioc_get_adapter_model(&fabric->fcs->bfa->ioc, model); bfa_ioc_get_adapter_model(&fabric->fcs->bfa->ioc, model);
/* Model name/number */ /* Model name/number */
strncpy((char *)&port_cfg->node_sym_name, model, strlcpy(port_cfg->node_sym_name.symname, model,
BFA_FCS_PORT_SYMBNAME_MODEL_SZ); BFA_SYMNAME_MAXLEN);
strncat((char *)&port_cfg->node_sym_name, strlcat(port_cfg->node_sym_name.symname,
BFA_FCS_PORT_SYMBNAME_SEPARATOR, BFA_FCS_PORT_SYMBNAME_SEPARATOR,
sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR)); BFA_SYMNAME_MAXLEN);
/* Driver Version */ /* Driver Version */
strncat((char *)&port_cfg->node_sym_name, (char *)driver_info->version, strlcat(port_cfg->node_sym_name.symname, (char *)driver_info->version,
BFA_FCS_PORT_SYMBNAME_VERSION_SZ); BFA_SYMNAME_MAXLEN);
strncat((char *)&port_cfg->node_sym_name, strlcat(port_cfg->node_sym_name.symname,
BFA_FCS_PORT_SYMBNAME_SEPARATOR, BFA_FCS_PORT_SYMBNAME_SEPARATOR,
sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR)); BFA_SYMNAME_MAXLEN);
/* Host machine name */ /* Host machine name */
strncat((char *)&port_cfg->node_sym_name, strlcat(port_cfg->node_sym_name.symname,
(char *)driver_info->host_machine_name, driver_info->host_machine_name,
BFA_FCS_PORT_SYMBNAME_MACHINENAME_SZ); BFA_SYMNAME_MAXLEN);
strncat((char *)&port_cfg->node_sym_name, strlcat(port_cfg->node_sym_name.symname,
BFA_FCS_PORT_SYMBNAME_SEPARATOR, BFA_FCS_PORT_SYMBNAME_SEPARATOR,
sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR)); BFA_SYMNAME_MAXLEN);
/* null terminate */ /* null terminate */
port_cfg->node_sym_name.symname[BFA_SYMNAME_MAXLEN - 1] = 0; port_cfg->node_sym_name.symname[BFA_SYMNAME_MAXLEN - 1] = 0;
......
...@@ -2630,10 +2630,10 @@ bfa_fcs_fdmi_get_hbaattr(struct bfa_fcs_lport_fdmi_s *fdmi, ...@@ -2630,10 +2630,10 @@ bfa_fcs_fdmi_get_hbaattr(struct bfa_fcs_lport_fdmi_s *fdmi,
bfa_ioc_get_adapter_fw_ver(&port->fcs->bfa->ioc, bfa_ioc_get_adapter_fw_ver(&port->fcs->bfa->ioc,
hba_attr->fw_version); hba_attr->fw_version);
strncpy(hba_attr->driver_version, (char *)driver_info->version, strlcpy(hba_attr->driver_version, (char *)driver_info->version,
sizeof(hba_attr->driver_version)); sizeof(hba_attr->driver_version));
strncpy(hba_attr->os_name, driver_info->host_os_name, strlcpy(hba_attr->os_name, driver_info->host_os_name,
sizeof(hba_attr->os_name)); sizeof(hba_attr->os_name));
/* /*
...@@ -2641,23 +2641,23 @@ bfa_fcs_fdmi_get_hbaattr(struct bfa_fcs_lport_fdmi_s *fdmi, ...@@ -2641,23 +2641,23 @@ bfa_fcs_fdmi_get_hbaattr(struct bfa_fcs_lport_fdmi_s *fdmi,
* to the os name along with a separator * to the os name along with a separator
*/ */
if (driver_info->host_os_patch[0] != '\0') { if (driver_info->host_os_patch[0] != '\0') {
strncat(hba_attr->os_name, BFA_FCS_PORT_SYMBNAME_SEPARATOR, strlcat(hba_attr->os_name, BFA_FCS_PORT_SYMBNAME_SEPARATOR,
sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR)); sizeof(hba_attr->os_name));
strncat(hba_attr->os_name, driver_info->host_os_patch, strlcat(hba_attr->os_name, driver_info->host_os_patch,
sizeof(driver_info->host_os_patch)); sizeof(hba_attr->os_name));
} }
/* Retrieve the max frame size from the port attr */ /* Retrieve the max frame size from the port attr */
bfa_fcs_fdmi_get_portattr(fdmi, &fcs_port_attr); bfa_fcs_fdmi_get_portattr(fdmi, &fcs_port_attr);
hba_attr->max_ct_pyld = fcs_port_attr.max_frm_size; hba_attr->max_ct_pyld = fcs_port_attr.max_frm_size;
strncpy(hba_attr->node_sym_name.symname, strlcpy(hba_attr->node_sym_name.symname,
port->port_cfg.node_sym_name.symname, BFA_SYMNAME_MAXLEN); port->port_cfg.node_sym_name.symname, BFA_SYMNAME_MAXLEN);
strcpy(hba_attr->vendor_info, "BROCADE"); strcpy(hba_attr->vendor_info, "BROCADE");
hba_attr->num_ports = hba_attr->num_ports =
cpu_to_be32(bfa_ioc_get_nports(&port->fcs->bfa->ioc)); cpu_to_be32(bfa_ioc_get_nports(&port->fcs->bfa->ioc));
hba_attr->fabric_name = port->fabric->lps->pr_nwwn; hba_attr->fabric_name = port->fabric->lps->pr_nwwn;
strncpy(hba_attr->bios_ver, hba_attr->option_rom_ver, BFA_VERSION_LEN); strlcpy(hba_attr->bios_ver, hba_attr->option_rom_ver, BFA_VERSION_LEN);
} }
...@@ -2724,20 +2724,20 @@ bfa_fcs_fdmi_get_portattr(struct bfa_fcs_lport_fdmi_s *fdmi, ...@@ -2724,20 +2724,20 @@ bfa_fcs_fdmi_get_portattr(struct bfa_fcs_lport_fdmi_s *fdmi,
/* /*
* OS device Name * OS device Name
*/ */
strncpy(port_attr->os_device_name, (char *)driver_info->os_device_name, strlcpy(port_attr->os_device_name, driver_info->os_device_name,
sizeof(port_attr->os_device_name)); sizeof(port_attr->os_device_name));
/* /*
* Host name * Host name
*/ */
strncpy(port_attr->host_name, (char *)driver_info->host_machine_name, strlcpy(port_attr->host_name, driver_info->host_machine_name,
sizeof(port_attr->host_name)); sizeof(port_attr->host_name));
port_attr->node_name = bfa_fcs_lport_get_nwwn(port); port_attr->node_name = bfa_fcs_lport_get_nwwn(port);
port_attr->port_name = bfa_fcs_lport_get_pwwn(port); port_attr->port_name = bfa_fcs_lport_get_pwwn(port);
strncpy(port_attr->port_sym_name.symname, strlcpy(port_attr->port_sym_name.symname,
(char *)&bfa_fcs_lport_get_psym_name(port), BFA_SYMNAME_MAXLEN); bfa_fcs_lport_get_psym_name(port).symname, BFA_SYMNAME_MAXLEN);
bfa_fcs_lport_get_attr(port, &lport_attr); bfa_fcs_lport_get_attr(port, &lport_attr);
port_attr->port_type = cpu_to_be32(lport_attr.port_type); port_attr->port_type = cpu_to_be32(lport_attr.port_type);
port_attr->scos = pport_attr.cos_supported; port_attr->scos = pport_attr.cos_supported;
...@@ -3217,7 +3217,7 @@ bfa_fcs_lport_ms_gmal_response(void *fcsarg, struct bfa_fcxp_s *fcxp, ...@@ -3217,7 +3217,7 @@ bfa_fcs_lport_ms_gmal_response(void *fcsarg, struct bfa_fcxp_s *fcxp,
rsp_str[gmal_entry->len-1] = 0; rsp_str[gmal_entry->len-1] = 0;
/* copy IP Address to fabric */ /* copy IP Address to fabric */
strncpy(bfa_fcs_lport_get_fabric_ipaddr(port), strlcpy(bfa_fcs_lport_get_fabric_ipaddr(port),
gmal_entry->ip_addr, gmal_entry->ip_addr,
BFA_FCS_FABRIC_IPADDR_SZ); BFA_FCS_FABRIC_IPADDR_SZ);
break; break;
...@@ -4655,21 +4655,13 @@ bfa_fcs_lport_ns_send_rspn_id(void *ns_cbarg, struct bfa_fcxp_s *fcxp_alloced) ...@@ -4655,21 +4655,13 @@ bfa_fcs_lport_ns_send_rspn_id(void *ns_cbarg, struct bfa_fcxp_s *fcxp_alloced)
* to that of the base port. * to that of the base port.
*/ */
strncpy((char *)psymbl, strlcpy(symbl,
(char *) & (char *)&(bfa_fcs_lport_get_psym_name
(bfa_fcs_lport_get_psym_name
(bfa_fcs_get_base_port(port->fcs))), (bfa_fcs_get_base_port(port->fcs))),
strlen((char *) & sizeof(symbl));
bfa_fcs_lport_get_psym_name(bfa_fcs_get_base_port
(port->fcs)))); strlcat(symbl, (char *)&(bfa_fcs_lport_get_psym_name(port)),
sizeof(symbl));
/* Ensure we have a null terminating string. */
((char *)psymbl)[strlen((char *) &
bfa_fcs_lport_get_psym_name(bfa_fcs_get_base_port
(port->fcs)))] = 0;
strncat((char *)psymbl,
(char *) &(bfa_fcs_lport_get_psym_name(port)),
strlen((char *) &bfa_fcs_lport_get_psym_name(port)));
} else { } else {
psymbl = (u8 *) &(bfa_fcs_lport_get_psym_name(port)); psymbl = (u8 *) &(bfa_fcs_lport_get_psym_name(port));
} }
...@@ -5161,7 +5153,6 @@ bfa_fcs_lport_ns_util_send_rspn_id(void *cbarg, struct bfa_fcxp_s *fcxp_alloced) ...@@ -5161,7 +5153,6 @@ bfa_fcs_lport_ns_util_send_rspn_id(void *cbarg, struct bfa_fcxp_s *fcxp_alloced)
struct fchs_s fchs; struct fchs_s fchs;
struct bfa_fcxp_s *fcxp; struct bfa_fcxp_s *fcxp;
u8 symbl[256]; u8 symbl[256];
u8 *psymbl = &symbl[0];
int len; int len;
/* Avoid sending RSPN in the following states. */ /* Avoid sending RSPN in the following states. */
...@@ -5191,22 +5182,17 @@ bfa_fcs_lport_ns_util_send_rspn_id(void *cbarg, struct bfa_fcxp_s *fcxp_alloced) ...@@ -5191,22 +5182,17 @@ bfa_fcs_lport_ns_util_send_rspn_id(void *cbarg, struct bfa_fcxp_s *fcxp_alloced)
* For Vports, we append the vport's port symbolic name * For Vports, we append the vport's port symbolic name
* to that of the base port. * to that of the base port.
*/ */
strncpy((char *)psymbl, (char *)&(bfa_fcs_lport_get_psym_name strlcpy(symbl, (char *)&(bfa_fcs_lport_get_psym_name
(bfa_fcs_get_base_port(port->fcs))), (bfa_fcs_get_base_port(port->fcs))),
strlen((char *)&bfa_fcs_lport_get_psym_name( sizeof(symbl));
bfa_fcs_get_base_port(port->fcs))));
/* Ensure we have a null terminating string. */
((char *)psymbl)[strlen((char *)&bfa_fcs_lport_get_psym_name(
bfa_fcs_get_base_port(port->fcs)))] = 0;
strncat((char *)psymbl, strlcat(symbl,
(char *)&(bfa_fcs_lport_get_psym_name(port)), (char *)&(bfa_fcs_lport_get_psym_name(port)),
strlen((char *)&bfa_fcs_lport_get_psym_name(port))); sizeof(symbl));
} }
len = fc_rspnid_build(&fchs, bfa_fcxp_get_reqbuf(fcxp), len = fc_rspnid_build(&fchs, bfa_fcxp_get_reqbuf(fcxp),
bfa_fcs_lport_get_fcid(port), 0, psymbl); bfa_fcs_lport_get_fcid(port), 0, symbl);
bfa_fcxp_send(fcxp, NULL, port->fabric->vf_id, port->lp_tag, BFA_FALSE, bfa_fcxp_send(fcxp, NULL, port->fabric->vf_id, port->lp_tag, BFA_FALSE,
FC_CLASS_3, len, &fchs, NULL, NULL, FC_MAX_PDUSZ, 0); FC_CLASS_3, len, &fchs, NULL, NULL, FC_MAX_PDUSZ, 0);
......
...@@ -2802,7 +2802,7 @@ void ...@@ -2802,7 +2802,7 @@ void
bfa_ioc_get_adapter_manufacturer(struct bfa_ioc_s *ioc, char *manufacturer) bfa_ioc_get_adapter_manufacturer(struct bfa_ioc_s *ioc, char *manufacturer)
{ {
memset((void *)manufacturer, 0, BFA_ADAPTER_MFG_NAME_LEN); memset((void *)manufacturer, 0, BFA_ADAPTER_MFG_NAME_LEN);
memcpy(manufacturer, BFA_MFG_NAME, BFA_ADAPTER_MFG_NAME_LEN); strlcpy(manufacturer, BFA_MFG_NAME, BFA_ADAPTER_MFG_NAME_LEN);
} }
void void
......
...@@ -365,8 +365,8 @@ bfa_plog_str(struct bfa_plog_s *plog, enum bfa_plog_mid mid, ...@@ -365,8 +365,8 @@ bfa_plog_str(struct bfa_plog_s *plog, enum bfa_plog_mid mid,
lp.eid = event; lp.eid = event;
lp.log_type = BFA_PL_LOG_TYPE_STRING; lp.log_type = BFA_PL_LOG_TYPE_STRING;
lp.misc = misc; lp.misc = misc;
strncpy(lp.log_entry.string_log, log_str, strlcpy(lp.log_entry.string_log, log_str,
BFA_PL_STRING_LOG_SZ - 1); BFA_PL_STRING_LOG_SZ);
lp.log_entry.string_log[BFA_PL_STRING_LOG_SZ - 1] = '\0'; lp.log_entry.string_log[BFA_PL_STRING_LOG_SZ - 1] = '\0';
bfa_plog_add(plog, &lp); bfa_plog_add(plog, &lp);
} }
......
...@@ -987,20 +987,20 @@ bfad_start_ops(struct bfad_s *bfad) { ...@@ -987,20 +987,20 @@ bfad_start_ops(struct bfad_s *bfad) {
/* Fill the driver_info info to fcs*/ /* Fill the driver_info info to fcs*/
memset(&driver_info, 0, sizeof(driver_info)); memset(&driver_info, 0, sizeof(driver_info));
strncpy(driver_info.version, BFAD_DRIVER_VERSION, strlcpy(driver_info.version, BFAD_DRIVER_VERSION,
sizeof(driver_info.version) - 1); sizeof(driver_info.version));
if (host_name) if (host_name)
strncpy(driver_info.host_machine_name, host_name, strlcpy(driver_info.host_machine_name, host_name,
sizeof(driver_info.host_machine_name) - 1); sizeof(driver_info.host_machine_name));
if (os_name) if (os_name)
strncpy(driver_info.host_os_name, os_name, strlcpy(driver_info.host_os_name, os_name,
sizeof(driver_info.host_os_name) - 1); sizeof(driver_info.host_os_name));
if (os_patch) if (os_patch)
strncpy(driver_info.host_os_patch, os_patch, strlcpy(driver_info.host_os_patch, os_patch,
sizeof(driver_info.host_os_patch) - 1); sizeof(driver_info.host_os_patch));
strncpy(driver_info.os_device_name, bfad->pci_name, strlcpy(driver_info.os_device_name, bfad->pci_name,
sizeof(driver_info.os_device_name) - 1); sizeof(driver_info.os_device_name));
/* FCS driver info init */ /* FCS driver info init */
spin_lock_irqsave(&bfad->bfad_lock, flags); spin_lock_irqsave(&bfad->bfad_lock, flags);
......
...@@ -842,7 +842,7 @@ bfad_im_symbolic_name_show(struct device *dev, struct device_attribute *attr, ...@@ -842,7 +842,7 @@ bfad_im_symbolic_name_show(struct device *dev, struct device_attribute *attr,
char symname[BFA_SYMNAME_MAXLEN]; char symname[BFA_SYMNAME_MAXLEN];
bfa_fcs_lport_get_attr(&bfad->bfa_fcs.fabric.bport, &port_attr); bfa_fcs_lport_get_attr(&bfad->bfa_fcs.fabric.bport, &port_attr);
strncpy(symname, port_attr.port_cfg.sym_name.symname, strlcpy(symname, port_attr.port_cfg.sym_name.symname,
BFA_SYMNAME_MAXLEN); BFA_SYMNAME_MAXLEN);
return snprintf(buf, PAGE_SIZE, "%s\n", symname); return snprintf(buf, PAGE_SIZE, "%s\n", symname);
} }
......
...@@ -126,7 +126,7 @@ bfad_iocmd_ioc_get_attr(struct bfad_s *bfad, void *cmd) ...@@ -126,7 +126,7 @@ bfad_iocmd_ioc_get_attr(struct bfad_s *bfad, void *cmd)
/* fill in driver attr info */ /* fill in driver attr info */
strcpy(iocmd->ioc_attr.driver_attr.driver, BFAD_DRIVER_NAME); strcpy(iocmd->ioc_attr.driver_attr.driver, BFAD_DRIVER_NAME);
strncpy(iocmd->ioc_attr.driver_attr.driver_ver, strlcpy(iocmd->ioc_attr.driver_attr.driver_ver,
BFAD_DRIVER_VERSION, BFA_VERSION_LEN); BFAD_DRIVER_VERSION, BFA_VERSION_LEN);
strcpy(iocmd->ioc_attr.driver_attr.fw_ver, strcpy(iocmd->ioc_attr.driver_attr.fw_ver,
iocmd->ioc_attr.adapter_attr.fw_ver); iocmd->ioc_attr.adapter_attr.fw_ver);
...@@ -314,9 +314,9 @@ bfad_iocmd_port_get_attr(struct bfad_s *bfad, void *cmd) ...@@ -314,9 +314,9 @@ bfad_iocmd_port_get_attr(struct bfad_s *bfad, void *cmd)
iocmd->attr.port_type = port_attr.port_type; iocmd->attr.port_type = port_attr.port_type;
iocmd->attr.loopback = port_attr.loopback; iocmd->attr.loopback = port_attr.loopback;
iocmd->attr.authfail = port_attr.authfail; iocmd->attr.authfail = port_attr.authfail;
strncpy(iocmd->attr.port_symname.symname, strlcpy(iocmd->attr.port_symname.symname,
port_attr.port_cfg.sym_name.symname, port_attr.port_cfg.sym_name.symname,
sizeof(port_attr.port_cfg.sym_name.symname)); sizeof(iocmd->attr.port_symname.symname));
iocmd->status = BFA_STATUS_OK; iocmd->status = BFA_STATUS_OK;
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment