Merge tag 'fixes-v5.10a' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris...
[linux-2.6-microblaze.git] / fs / cifs / cifs_unicode.c
index 498777d..9bd03a2 100644 (file)
@@ -488,7 +488,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;