summaryrefslogtreecommitdiffstats
path: root/drivers/target/iscsi/iscsi_target_auth.c
diff options
context:
space:
mode:
authorNicholas Bellinger <nab@linux-iscsi.org>2014-06-13 06:05:16 +0200
committerNicholas Bellinger <nab@linux-iscsi.org>2014-06-27 05:56:42 +0200
commitb06eef6eab8e4a241f88385527ac4d1844abc18d (patch)
treeb1f3ac91024dba8446faf19cd3ca66238fd82155 /drivers/target/iscsi/iscsi_target_auth.c
parentLinux 3.16-rc2 (diff)
downloadlinux-b06eef6eab8e4a241f88385527ac4d1844abc18d.tar.xz
linux-b06eef6eab8e4a241f88385527ac4d1844abc18d.zip
iscsi-target: Convert chap_server_compute_md5 to use kstrtoul
This patch converts chap_server_compute_md5() from simple_strtoul() to kstrtoul usage(). This addresses the case where a empty 'CHAP_I=' key value received during mutual authentication would be converted to a '0' by simple_strtoul(), instead of failing the login attempt. Reported-by: Tejas Vaykole <tejas.vaykole@calsoftinc.com> Tested-by: Tejas Vaykole <tejas.vaykole@calsoftinc.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to '')
-rw-r--r--drivers/target/iscsi/iscsi_target_auth.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/drivers/target/iscsi/iscsi_target_auth.c b/drivers/target/iscsi/iscsi_target_auth.c
index 19b842c3e0b3..9430eea7c0d6 100644
--- a/drivers/target/iscsi/iscsi_target_auth.c
+++ b/drivers/target/iscsi/iscsi_target_auth.c
@@ -174,7 +174,6 @@ static int chap_server_compute_md5(
char *nr_out_ptr,
unsigned int *nr_out_len)
{
- char *endptr;
unsigned long id;
unsigned char id_as_uchar;
unsigned char digest[MD5_SIGNATURE_SIZE];
@@ -320,9 +319,14 @@ static int chap_server_compute_md5(
}
if (type == HEX)
- id = simple_strtoul(&identifier[2], &endptr, 0);
+ ret = kstrtoul(&identifier[2], 0, &id);
else
- id = simple_strtoul(identifier, &endptr, 0);
+ ret = kstrtoul(identifier, 0, &id);
+
+ if (ret < 0) {
+ pr_err("kstrtoul() failed for CHAP identifier: %d\n", ret);
+ goto out;
+ }
if (id > 255) {
pr_err("chap identifier: %lu greater than 255\n", id);
goto out;