scsi: target: compare full CHAP_A Algorithm strings
authorDavid Disseldorp <ddiss@suse.de>
Thu, 12 Sep 2019 09:55:45 +0000 (11:55 +0200)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 23 Oct 2019 02:14:24 +0000 (22:14 -0400)
RFC 2307 states:

  For CHAP [RFC1994], in the first step, the initiator MUST send:

      CHAP_A=<A1,A2...>

   Where A1,A2... are proposed algorithms, in order of preference.
...
   For the Algorithm, as stated in [RFC1994], one value is required to
   be implemented:

       5     (CHAP with MD5)

LIO currently checks for this value by only comparing a single byte in
the tokenized Algorithm string, which means that any value starting with
a '5' (e.g. "55") is interpreted as "CHAP with MD5". Fix this by
comparing the entire tokenized string.

Reviewed-by: Lee Duncan <lduncan@suse.com>
Reviewed-by: Mike Christie <mchristi@redhat.com>
Signed-off-by: David Disseldorp <ddiss@suse.de>
Link: https://lore.kernel.org/r/20190912095547.22427-2-ddiss@suse.de
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/target/iscsi/iscsi_target_auth.c

index 51ddca2033e0aad75c9b38e70b1d60b8970b5ccc..8fe9b12a07a4d3bce2027d73c55b5f1c7d403a4a 100644 (file)
@@ -70,7 +70,7 @@ static int chap_check_algorithm(const char *a_str)
                if (!token)
                        goto out;
 
-               if (!strncmp(token, "5", 1)) {
+               if (!strcmp(token, "5")) {
                        pr_debug("Selected MD5 Algorithm\n");
                        kfree(orig);
                        return CHAP_DIGEST_MD5;