aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRickard Strandqvist <rickard_strandqvist@spectrumdigital.se>2014-07-27 10:57:42 -0400
committerChristoph Hellwig <hch@lst.de>2014-07-30 07:49:36 -0400
commit4d0a21f1fd31adb3ec66db4c1af3856ae0b8549f (patch)
treec3c54a8e54c6c5504b79c77d1f37d29aa1821b97
parentbdbb9662f7b18197cadb729f1d97e5646546179a (diff)
scsi: qla4xxx: ql4_mbx.c: Cleaning up missing null-terminate in conjunction with strncpy
Replacing strncpy with strlcpy to avoid strings that lacks null terminate. And in some cases modified to copy one character less than the overall length, as the entire area is already zeroed. Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se> Acked-By: Nilesh Javali <nilesh.javali@qlogic.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
-rw-r--r--drivers/scsi/qla4xxx/ql4_mbx.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/drivers/scsi/qla4xxx/ql4_mbx.c b/drivers/scsi/qla4xxx/ql4_mbx.c
index fdfae79924ac..c291fdff1b33 100644
--- a/drivers/scsi/qla4xxx/ql4_mbx.c
+++ b/drivers/scsi/qla4xxx/ql4_mbx.c
@@ -1620,8 +1620,8 @@ int qla4xxx_get_chap(struct scsi_qla_host *ha, char *username, char *password,
1620 goto exit_get_chap; 1620 goto exit_get_chap;
1621 } 1621 }
1622 1622
1623 strncpy(password, chap_table->secret, QL4_CHAP_MAX_SECRET_LEN); 1623 strlcpy(password, chap_table->secret, QL4_CHAP_MAX_SECRET_LEN);
1624 strncpy(username, chap_table->name, QL4_CHAP_MAX_NAME_LEN); 1624 strlcpy(username, chap_table->name, QL4_CHAP_MAX_NAME_LEN);
1625 chap_table->cookie = __constant_cpu_to_le16(CHAP_VALID_COOKIE); 1625 chap_table->cookie = __constant_cpu_to_le16(CHAP_VALID_COOKIE);
1626 1626
1627exit_get_chap: 1627exit_get_chap:
@@ -1663,8 +1663,8 @@ int qla4xxx_set_chap(struct scsi_qla_host *ha, char *username, char *password,
1663 else 1663 else
1664 chap_table->flags |= BIT_7; /* local */ 1664 chap_table->flags |= BIT_7; /* local */
1665 chap_table->secret_len = strlen(password); 1665 chap_table->secret_len = strlen(password);
1666 strncpy(chap_table->secret, password, MAX_CHAP_SECRET_LEN); 1666 strncpy(chap_table->secret, password, MAX_CHAP_SECRET_LEN - 1);
1667 strncpy(chap_table->name, username, MAX_CHAP_NAME_LEN); 1667 strncpy(chap_table->name, username, MAX_CHAP_NAME_LEN - 1);
1668 chap_table->cookie = __constant_cpu_to_le16(CHAP_VALID_COOKIE); 1668 chap_table->cookie = __constant_cpu_to_le16(CHAP_VALID_COOKIE);
1669 1669
1670 if (is_qla40XX(ha)) { 1670 if (is_qla40XX(ha)) {
@@ -1742,8 +1742,8 @@ int qla4xxx_get_uni_chap_at_index(struct scsi_qla_host *ha, char *username,
1742 goto exit_unlock_uni_chap; 1742 goto exit_unlock_uni_chap;
1743 } 1743 }
1744 1744
1745 strncpy(password, chap_table->secret, MAX_CHAP_SECRET_LEN); 1745 strlcpy(password, chap_table->secret, MAX_CHAP_SECRET_LEN);
1746 strncpy(username, chap_table->name, MAX_CHAP_NAME_LEN); 1746 strlcpy(username, chap_table->name, MAX_CHAP_NAME_LEN);
1747 1747
1748 rval = QLA_SUCCESS; 1748 rval = QLA_SUCCESS;
1749 1749
@@ -2295,7 +2295,7 @@ int qla4_8xxx_set_param(struct scsi_qla_host *ha, int param)
2295 if (param == SET_DRVR_VERSION) { 2295 if (param == SET_DRVR_VERSION) {
2296 mbox_cmd[1] = SET_DRVR_VERSION; 2296 mbox_cmd[1] = SET_DRVR_VERSION;
2297 strncpy((char *)&mbox_cmd[2], QLA4XXX_DRIVER_VERSION, 2297 strncpy((char *)&mbox_cmd[2], QLA4XXX_DRIVER_VERSION,
2298 MAX_DRVR_VER_LEN); 2298 MAX_DRVR_VER_LEN - 1);
2299 } else { 2299 } else {
2300 ql4_printk(KERN_ERR, ha, "%s: invalid parameter 0x%x\n", 2300 ql4_printk(KERN_ERR, ha, "%s: invalid parameter 0x%x\n",
2301 __func__, param); 2301 __func__, param);