diff options
author | Andrew Vasquez <andrew.vasquez@cavium.com> | 2018-02-07 11:12:35 -0500 |
---|---|---|
committer | Martin K. Petersen <martin.petersen@oracle.com> | 2018-02-13 21:35:39 -0500 |
commit | 1683ce57f568c7c92d53e9234624a53554a29cd5 (patch) | |
tree | 1010454f842fd744423801b10697d4b867f7e88d | |
parent | f3767225021a48fc419d963559793e585da88b3d (diff) |
scsi: qedi: Fix truncation of CHAP name and secret
The data in NVRAM is not guaranteed to be NUL terminated. Since
snprintf expects byte-stream to accommodate null byte, the CHAP secret
is truncated. Use sprintf instead of snprintf to fix the truncation of
CHAP name and secret.
Signed-off-by: Andrew Vasquez <andrew.vasquez@cavium.com>
Signed-off-by: Nilesh Javali <nilesh.javali@cavium.com>
Reviewed-by: Bart Van Assche <bart.vanassche@wdc.com>
Acked-by: Chris Leech <cleech@redhat.com>
Acked-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
-rw-r--r-- | drivers/scsi/qedi/qedi_main.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/drivers/scsi/qedi/qedi_main.c b/drivers/scsi/qedi/qedi_main.c index 58596d17f7d9..7c05be680b94 100644 --- a/drivers/scsi/qedi/qedi_main.c +++ b/drivers/scsi/qedi/qedi_main.c | |||
@@ -1830,8 +1830,8 @@ static ssize_t qedi_show_boot_ini_info(void *data, int type, char *buf) | |||
1830 | 1830 | ||
1831 | switch (type) { | 1831 | switch (type) { |
1832 | case ISCSI_BOOT_INI_INITIATOR_NAME: | 1832 | case ISCSI_BOOT_INI_INITIATOR_NAME: |
1833 | rc = snprintf(str, NVM_ISCSI_CFG_ISCSI_NAME_MAX_LEN, "%s\n", | 1833 | rc = sprintf(str, "%.*s\n", NVM_ISCSI_CFG_ISCSI_NAME_MAX_LEN, |
1834 | initiator->initiator_name.byte); | 1834 | initiator->initiator_name.byte); |
1835 | break; | 1835 | break; |
1836 | default: | 1836 | default: |
1837 | rc = 0; | 1837 | rc = 0; |
@@ -1898,8 +1898,8 @@ qedi_show_boot_tgt_info(struct qedi_ctx *qedi, int type, | |||
1898 | 1898 | ||
1899 | switch (type) { | 1899 | switch (type) { |
1900 | case ISCSI_BOOT_TGT_NAME: | 1900 | case ISCSI_BOOT_TGT_NAME: |
1901 | rc = snprintf(str, NVM_ISCSI_CFG_ISCSI_NAME_MAX_LEN, "%s\n", | 1901 | rc = sprintf(str, "%.*s\n", NVM_ISCSI_CFG_ISCSI_NAME_MAX_LEN, |
1902 | block->target[idx].target_name.byte); | 1902 | block->target[idx].target_name.byte); |
1903 | break; | 1903 | break; |
1904 | case ISCSI_BOOT_TGT_IP_ADDR: | 1904 | case ISCSI_BOOT_TGT_IP_ADDR: |
1905 | if (ipv6_en) | 1905 | if (ipv6_en) |
@@ -1920,20 +1920,20 @@ qedi_show_boot_tgt_info(struct qedi_ctx *qedi, int type, | |||
1920 | block->target[idx].lun.value[0]); | 1920 | block->target[idx].lun.value[0]); |
1921 | break; | 1921 | break; |
1922 | case ISCSI_BOOT_TGT_CHAP_NAME: | 1922 | case ISCSI_BOOT_TGT_CHAP_NAME: |
1923 | rc = snprintf(str, NVM_ISCSI_CFG_CHAP_NAME_MAX_LEN, "%s\n", | 1923 | rc = sprintf(str, "%.*s\n", NVM_ISCSI_CFG_CHAP_NAME_MAX_LEN, |
1924 | chap_name); | 1924 | chap_name); |
1925 | break; | 1925 | break; |
1926 | case ISCSI_BOOT_TGT_CHAP_SECRET: | 1926 | case ISCSI_BOOT_TGT_CHAP_SECRET: |
1927 | rc = snprintf(str, NVM_ISCSI_CFG_CHAP_PWD_MAX_LEN, "%s\n", | 1927 | rc = sprintf(str, "%.*s\n", NVM_ISCSI_CFG_CHAP_NAME_MAX_LEN, |
1928 | chap_secret); | 1928 | chap_secret); |
1929 | break; | 1929 | break; |
1930 | case ISCSI_BOOT_TGT_REV_CHAP_NAME: | 1930 | case ISCSI_BOOT_TGT_REV_CHAP_NAME: |
1931 | rc = snprintf(str, NVM_ISCSI_CFG_CHAP_NAME_MAX_LEN, "%s\n", | 1931 | rc = sprintf(str, "%.*s\n", NVM_ISCSI_CFG_CHAP_NAME_MAX_LEN, |
1932 | mchap_name); | 1932 | mchap_name); |
1933 | break; | 1933 | break; |
1934 | case ISCSI_BOOT_TGT_REV_CHAP_SECRET: | 1934 | case ISCSI_BOOT_TGT_REV_CHAP_SECRET: |
1935 | rc = snprintf(str, NVM_ISCSI_CFG_CHAP_PWD_MAX_LEN, "%s\n", | 1935 | rc = sprintf(str, "%.*s\n", NVM_ISCSI_CFG_CHAP_NAME_MAX_LEN, |
1936 | mchap_secret); | 1936 | mchap_secret); |
1937 | break; | 1937 | break; |
1938 | case ISCSI_BOOT_TGT_FLAGS: | 1938 | case ISCSI_BOOT_TGT_FLAGS: |
1939 | rc = snprintf(str, 3, "%hhd\n", SYSFS_FLAG_FW_SEL_BOOT); | 1939 | rc = snprintf(str, 3, "%hhd\n", SYSFS_FLAG_FW_SEL_BOOT); |