aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicholas Bellinger <nab@linux-iscsi.org>2011-11-28 04:02:07 -0500
committerNicholas Bellinger <nab@linux-iscsi.org>2011-12-14 06:28:09 -0500
commitbc704fb58f507deea84a4c047a3a71351f0c55aa (patch)
tree64372a6e7fbf1a54214fda904a81637d8bba1402
parent8359cf43b9dccddeebb0d247146719a14ce6371a (diff)
iscsi-target: fix chap identifier simple_strtoul usage
This patch makes chap_server_compute_md5() use proper unsigned long usage for the CHAP_I (identifier) and check for values beyond 255 as per RFC-1994. Reported-by: Joern Engel <joern@logfs.org> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
-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 92a2526f0a20..db0cf7c8adde 100644
--- a/drivers/target/iscsi/iscsi_target_auth.c
+++ b/drivers/target/iscsi/iscsi_target_auth.c
@@ -165,7 +165,8 @@ static int chap_server_compute_md5(
165 unsigned int *nr_out_len) 165 unsigned int *nr_out_len)
166{ 166{
167 char *endptr; 167 char *endptr;
168 unsigned char id, digest[MD5_SIGNATURE_SIZE]; 168 unsigned long id;
169 unsigned char digest[MD5_SIGNATURE_SIZE];
169 unsigned char type, response[MD5_SIGNATURE_SIZE * 2 + 2]; 170 unsigned char type, response[MD5_SIGNATURE_SIZE * 2 + 2];
170 unsigned char identifier[10], *challenge = NULL; 171 unsigned char identifier[10], *challenge = NULL;
171 unsigned char *challenge_binhex = NULL; 172 unsigned char *challenge_binhex = NULL;
@@ -304,15 +305,18 @@ static int chap_server_compute_md5(
304 goto out; 305 goto out;
305 } 306 }
306 307
307 /* FIXME: What happens when simple_strtoul() return 256, 257, etc.? */
308 if (type == HEX) 308 if (type == HEX)
309 id = simple_strtoul(&identifier[2], &endptr, 0); 309 id = simple_strtoul(&identifier[2], &endptr, 0);
310 else 310 else
311 id = simple_strtoul(identifier, &endptr, 0); 311 id = simple_strtoul(identifier, &endptr, 0);
312 if (id > 255) {
313 pr_err("chap identifier: %lu greater than 255\n", id);
314 goto out;
315 }
312 /* 316 /*
313 * RFC 1994 says Identifier is no more than octet (8 bits). 317 * RFC 1994 says Identifier is no more than octet (8 bits).
314 */ 318 */
315 pr_debug("[server] Got CHAP_I=%d\n", id); 319 pr_debug("[server] Got CHAP_I=%lu\n", id);
316 /* 320 /*
317 * Get CHAP_C. 321 * Get CHAP_C.
318 */ 322 */