Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1f5d0686 authored by Steve French's avatar Steve French Committed by Sasha Levin
Browse files

File names with trailing period or space need special case conversion



[ Upstream commit 45e8a2583d97ca758a55c608f78c4cef562644d1 ]

POSIX allows files with trailing spaces or a trailing period but
SMB3 does not, so convert these using the normal Services For Mac
mapping as we do for other reserved characters such as
	: < > | ? *
This is similar to what Macs do for the same problem over SMB3.

CC: Stable <stable@vger.kernel.org>
Signed-off-by: default avatarSteve French <steve.french@primarydata.com>
Acked-by: default avatarPavel Shilovsky <pshilovsky@samba.org>
Signed-off-by: default avatarSasha Levin <sasha.levin@oracle.com>
parent 59b52045
Loading
Loading
Loading
Loading
+29 −4
Original line number Diff line number Diff line
@@ -136,6 +136,12 @@ convert_sfm_char(const __u16 src_char, char *target)
	case SFM_SLASH:
		*target = '\\';
		break;
	case SFM_SPACE:
		*target = ' ';
		break;
	case SFM_PERIOD:
		*target = '.';
		break;
	default:
		return false;
	}
@@ -364,7 +370,7 @@ static __le16 convert_to_sfu_char(char src_char)
	return dest_char;
}

static __le16 convert_to_sfm_char(char src_char)
static __le16 convert_to_sfm_char(char src_char, bool end_of_string)
{
	__le16 dest_char;

@@ -387,6 +393,18 @@ static __le16 convert_to_sfm_char(char src_char)
	case '|':
		dest_char = cpu_to_le16(SFM_PIPE);
		break;
	case '.':
		if (end_of_string)
			dest_char = cpu_to_le16(SFM_PERIOD);
		else
			dest_char = 0;
		break;
	case ' ':
		if (end_of_string)
			dest_char = cpu_to_le16(SFM_SPACE);
		else
			dest_char = 0;
		break;
	default:
		dest_char = 0;
	}
@@ -424,9 +442,16 @@ cifsConvertToUTF16(__le16 *target, const char *source, int srclen,
		/* see if we must remap this char */
		if (map_chars == SFU_MAP_UNI_RSVD)
			dst_char = convert_to_sfu_char(src_char);
		else if (map_chars == SFM_MAP_UNI_RSVD)
			dst_char = convert_to_sfm_char(src_char);
		else if (map_chars == SFM_MAP_UNI_RSVD) {
			bool end_of_string;

			if (i == srclen - 1)
				end_of_string = true;
			else
				end_of_string = false;

			dst_char = convert_to_sfm_char(src_char, end_of_string);
		} else
			dst_char = 0;
		/*
		 * FIXME: We can not handle remapping backslash (UNI_SLASH)
+2 −0
Original line number Diff line number Diff line
@@ -64,6 +64,8 @@
#define SFM_LESSTHAN    ((__u16) 0xF023)
#define SFM_PIPE        ((__u16) 0xF027)
#define SFM_SLASH       ((__u16) 0xF026)
#define SFM_PERIOD	((__u16) 0xF028)
#define SFM_SPACE	((__u16) 0xF029)

/*
 * Mapping mechanism to use when one of the seven reserved characters is