diff options
author | Boris Protopopov <pboris@amazon.com> | 2020-09-24 00:36:38 +0000 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-11-18 18:25:04 +0100 |
commit | 4000c1b820087964a8c68cf7d5de71036f962107 (patch) | |
tree | 01af14fa2dac7b753143a8af02895b800a29cdec /fs/cifs | |
parent | 428f824e9df4888836e9a3f2d132cbf10783e61a (diff) | |
download | linux-stable-4000c1b820087964a8c68cf7d5de71036f962107.tar.gz linux-stable-4000c1b820087964a8c68cf7d5de71036f962107.tar.bz2 linux-stable-4000c1b820087964a8c68cf7d5de71036f962107.zip |
Convert trailing spaces and periods in path components
commit 57c176074057531b249cf522d90c22313fa74b0b 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>
Diffstat (limited to 'fs/cifs')
-rw-r--r-- | fs/cifs/cifs_unicode.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/fs/cifs/cifs_unicode.c b/fs/cifs/cifs_unicode.c index 211ac472cb9d..942874257a09 100644 --- a/fs/cifs/cifs_unicode.c +++ b/fs/cifs/cifs_unicode.c @@ -493,7 +493,13 @@ cifsConvertToUTF16(__le16 *target, const char *source, int srclen, else if (map_chars == SFM_MAP_UNI_RSVD) { bool end_of_string; - if (i == srclen - 1) + /** + * Remap spaces and periods found at the end of every + * component of the path. The special cases of '.' and + * '..' do not need to be dealt with explicitly because + * they are addressed in namei.c:link_path_walk(). + **/ + if ((i == srclen - 1) || (source[i+1] == '\\')) end_of_string = true; else end_of_string = false; |