diff options
author | Jeff Layton <jlayton@redhat.com> | 2012-12-10 06:10:45 -0500 |
---|---|---|
committer | Steve French <smfrench@gmail.com> | 2012-12-11 12:48:49 -0500 |
commit | 839db3d10a5ba792d6533b8bb3380f52ac877344 (patch) | |
tree | 5ef4cdeaa8d3fcb0a5ce6fa63da3f315d4661485 /fs/cifs/dir.c | |
parent | 62a1a439e0fdd4ec8a80dc00fcbb9f26b5c34de1 (diff) |
cifs: fix up handling of prefixpath= option
Currently the code takes care to ensure that the prefixpath has a
leading '/' delimiter. What if someone passes us a prefixpath with a
leading '\\' instead? The code doesn't properly handle that currently
AFAICS.
Let's just change the code to skip over any leading delimiter character
when copying the prepath. Then, fix up the users of the prepath option
to prefix it with the correct delimiter when they use it.
Also, there's no need to limit the length of the prefixpath to 1k. If
the server can handle it, why bother forbidding it?
Pavel Shilovsky <piastry@etersoft.ru>
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Steve French <smfrench@gmail.com>
Diffstat (limited to 'fs/cifs/dir.c')
-rw-r--r-- | fs/cifs/dir.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c index 3b7e0c1266f7..8719bbe0dcc3 100644 --- a/fs/cifs/dir.c +++ b/fs/cifs/dir.c | |||
@@ -48,7 +48,7 @@ char * | |||
48 | cifs_build_path_to_root(struct smb_vol *vol, struct cifs_sb_info *cifs_sb, | 48 | cifs_build_path_to_root(struct smb_vol *vol, struct cifs_sb_info *cifs_sb, |
49 | struct cifs_tcon *tcon) | 49 | struct cifs_tcon *tcon) |
50 | { | 50 | { |
51 | int pplen = vol->prepath ? strlen(vol->prepath) : 0; | 51 | int pplen = vol->prepath ? strlen(vol->prepath) + 1 : 0; |
52 | int dfsplen; | 52 | int dfsplen; |
53 | char *full_path = NULL; | 53 | char *full_path = NULL; |
54 | 54 | ||
@@ -69,7 +69,8 @@ cifs_build_path_to_root(struct smb_vol *vol, struct cifs_sb_info *cifs_sb, | |||
69 | 69 | ||
70 | if (dfsplen) | 70 | if (dfsplen) |
71 | strncpy(full_path, tcon->treeName, dfsplen); | 71 | strncpy(full_path, tcon->treeName, dfsplen); |
72 | strncpy(full_path + dfsplen, vol->prepath, pplen); | 72 | full_path[dfsplen] = CIFS_DIR_SEP(cifs_sb); |
73 | strncpy(full_path + dfsplen + 1, vol->prepath, pplen); | ||
73 | convert_delimiter(full_path, CIFS_DIR_SEP(cifs_sb)); | 74 | convert_delimiter(full_path, CIFS_DIR_SEP(cifs_sb)); |
74 | full_path[dfsplen + pplen] = 0; /* add trailing null */ | 75 | full_path[dfsplen + pplen] = 0; /* add trailing null */ |
75 | return full_path; | 76 | return full_path; |