Skip to content

Commit b06eef6

Browse files
author
Nicholas Bellinger
committed
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>
1 parent a497c3b commit b06eef6

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

‎drivers/target/iscsi/iscsi_target_auth.c‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ static int chap_server_compute_md5(
174174
char *nr_out_ptr,
175175
unsigned int *nr_out_len)
176176
{
177-
char *endptr;
178177
unsigned long id;
179178
unsigned char id_as_uchar;
180179
unsigned char digest[MD5_SIGNATURE_SIZE];
@@ -320,9 +319,14 @@ static int chap_server_compute_md5(
320319
}
321320

322321
if (type == HEX)
323-
id = simple_strtoul(&identifier[2], &endptr, 0);
322+
ret = kstrtoul(&identifier[2], 0, &id);
324323
else
325-
id = simple_strtoul(identifier, &endptr, 0);
324+
ret = kstrtoul(identifier, 0, &id);
325+
326+
if (ret < 0) {
327+
pr_err("kstrtoul() failed for CHAP identifier: %d\n", ret);
328+
goto out;
329+
}
326330
if (id > 255) {
327331
pr_err("chap identifier: %lu greater than 255\n", id);
328332
goto out;

0 commit comments

Comments
 (0)