Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Convert trailing spaces and periods in path components

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>

authored by

Boris Protopopov and committed by
Steve French
57c17607 bbf5c979

+7 -1
+7 -1
fs/cifs/cifs_unicode.c
··· 488 488 else if (map_chars == SFM_MAP_UNI_RSVD) { 489 489 bool end_of_string; 490 490 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] == '\\')) 492 498 end_of_string = true; 493 499 else 494 500 end_of_string = false;