Skip to content

Commit 9fda2e7

Browse files
Boris Protopopovgregkh
authored andcommitted
Convert trailing spaces and periods in path components
commit 57c1760 upstream. When converting trailing spaces and periods in paths, do so for every component of the path, not just the last component. If the conversion is not done for every path component, then subsequent operations in directories with trailing spaces or periods (e.g. create(), mkdir()) will fail with ENOENT. This is because on the server, the directory will have a special symbol in its name, and the client needs to provide the same. Signed-off-by: Boris Protopopov <pboris@amazon.com> Acked-by: Ronnie Sahlberg <lsahlber@redhat.com> Signed-off-by: Steve French <stfrench@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent ebc24ae commit 9fda2e7

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

fs/cifs/cifs_unicode.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,13 @@ cifsConvertToUTF16(__le16 *target, const char *source, int srclen,
488488
else if (map_chars == SFM_MAP_UNI_RSVD) {
489489
bool end_of_string;
490490

491-
if (i == srclen - 1)
491+
/**
492+
* Remap spaces and periods found at the end of every
493+
* component of the path. The special cases of '.' and
494+
* '..' do not need to be dealt with explicitly because
495+
* they are addressed in namei.c:link_path_walk().
496+
**/
497+
if ((i == srclen - 1) || (source[i+1] == '\\'))
492498
end_of_string = true;
493499
else
494500
end_of_string = false;

0 commit comments

Comments
 (0)