Re: [PATCH] : Unable to handle CHAP_A in List

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 05/27/2014 12:02 AM, Tejas Vaykole wrote:
Hi,

Initially the LIO target was not able to handle CHAP_A in list
correctly.This patch handles it correctly.
Let me know if any changes are required.

Hi Tejas,

Please include patch inline next time is possible, instead of as an attachment.

+/*
+ * check_algorithm -	Verifies CHAP_A string contains correct
+ *			algorithm value. Presently only MD5 is
+ *			supported.
+ *
+ * return values -	CHAP_DIGEST_UNKNOWN for unknown value and
+ *			CHAP_DIGEST_MD5 for MD5.
+ *
+ */
+static int check_algorithm(const char *a_str)
+{
+	char *tmp = NULL;
+	char *token = NULL;
+	tmp = kmalloc(strlen(a_str)+1, GFP_KERNEL);
+	if (tmp == NULL) {
+		pr_err("Memory allocation Failed\n");
+		return CHAP_DIGEST_UNKNOWN;
+	}
+	strcpy(tmp, a_str);
+	token = strsep(&tmp , "=");
+	while (token != NULL) {
+		token = strsep(&tmp , ",");
+		if (token == NULL)
+			return CHAP_DIGEST_UNKNOWN;
+		if (!strcmp(token, "5")) {
+			pr_err("MD5 Algorithm\n");
+			return CHAP_DIGEST_MD5;
+		}
+	}
+	return CHAP_DIGEST_UNKNOWN;
+}

Use strncpy over strcpy.
Free alloced memory, or else memory leak.

+
 static struct iscsi_chap *chap_server_open(
-	struct iscsi_conn *conn,
-	struct iscsi_node_auth *auth,
-	const char *a_str,
-	char *aic_str,
-	unsigned int *aic_len)
+		struct iscsi_conn *conn,
+		struct iscsi_node_auth *auth,
+		const char *a_str,
+		char *aic_str,
+		unsigned int *aic_len)
 {
+	int ret;
 	struct iscsi_chap *chap;
-
 	if (!(auth->naf_flags & NAF_USERID_SET) ||
-	    !(auth->naf_flags & NAF_PASSWORD_SET)) {

Your editor has modified some whitespace. Don't include whitespace fixes in substantive patches please.

Also, I'm sure I'm missing something, but how exactly does this fix the issue you described in your previous email? The current code in chap_server_open returns NULL if not "CHAP_A=5", which results in "security negotiation failed", doesn't it? And the new code doesn't change this behavior as far as I can see.

Thanks -- Regards -- Andy

--
To unsubscribe from this list: send the line "unsubscribe target-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux SCSI]     [Kernel Newbies]     [Linux SCSI Target Infrastructure]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Device Mapper]

  Powered by Linux