Commit d08395a3 authored by Ronnie Sahlberg's avatar Ronnie Sahlberg Committed by Steve French
Browse files

cifs: fix handling of escaped ',' in the password mount argument



Passwords can contain ',' which are also used as the separator between
mount options. Mount.cifs will escape all ',' characters as the string ",,".
Update parsing of the mount options to detect ",," and treat it as a single
'c' character.

Fixes: 24e0a1ef ("cifs: switch to new mount api")
Cc: stable@vger.kernel.org # 5.11
Reported-by: default avatarSimon Taylor <simon@simon-taylor.me.uk>
Tested-by: default avatarSimon Taylor <simon@simon-taylor.me.uk>
Signed-off-by: default avatarRonnie Sahlberg <lsahlber@redhat.com>
Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
parent 57804646
Loading
Loading
Loading
Loading
+30 −13
Original line number Diff line number Diff line
@@ -544,21 +544,38 @@ static int smb3_fs_context_parse_monolithic(struct fs_context *fc,

	/* BB Need to add support for sep= here TBD */
	while ((key = strsep(&options, ",")) != NULL) {
		if (*key) {
			size_t v_len = 0;
			char *value = strchr(key, '=');
		size_t len;
		char *value;

		if (*key == 0)
			break;

		/* Check if following character is the deliminator If yes,
		 * we have encountered a double deliminator reset the NULL
		 * character to the deliminator
		 */
		while (options && options[0] == ',') {
			len = strlen(key);
			strcpy(key + len, options);
			options = strchr(options, ',');
			if (options)
				*options++ = 0;
		}


		len = 0;
		value = strchr(key, '=');
		if (value) {
			if (value == key)
				continue;
			*value++ = 0;
				v_len = strlen(value);
			len = strlen(value);
		}
			ret = vfs_parse_fs_string(fc, key, value, v_len);

		ret = vfs_parse_fs_string(fc, key, value, len);
		if (ret < 0)
			break;
	}
	}

	return ret;
}