summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2007-03-08 03:00:42 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:18:28 -0500
commitdb32963181843c0ae425ee5a3bb517010ab0bf0f (patch)
tree39ef04f52870b9e3e0d622669813e0ff17a82063 /source3/smbd
parentc4ea95fd303ae6fd51d125e756c1289f440adbd2 (diff)
downloadsamba-db32963181843c0ae425ee5a3bb517010ab0bf0f.tar.gz
samba-db32963181843c0ae425ee5a3bb517010ab0bf0f.tar.bz2
samba-db32963181843c0ae425ee5a3bb517010ab0bf0f.zip
r21759: Fix the same bug in a more elegant way, strrchr_m
is an expensive call.... Jeremy. (This used to be commit 321a136dbce1a0532f123ea79ecb91f987b9a286)
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/msdfs.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/source3/smbd/msdfs.c b/source3/smbd/msdfs.c
index c34512493f..861588e6b7 100644
--- a/source3/smbd/msdfs.c
+++ b/source3/smbd/msdfs.c
@@ -331,6 +331,7 @@ static BOOL resolve_dfs_path(TALLOC_CTX *ctx,
SMB_STRUCT_STAT sbuf;
NTSTATUS status;
pstring reqpath;
+ pstring local_dfspath;
if (!dp || !conn) {
DEBUG(1,("resolve_dfs_path: NULL dfs_path* or NULL connection_struct*!\n"));
@@ -385,6 +386,12 @@ static BOOL resolve_dfs_path(TALLOC_CTX *ctx,
return True;
}
+ /* Prepare to test only for '/' components in the given path,
+ * so replace all '\\' characters with '/'. */
+
+ pstrcpy(local_dfspath, dfspath);
+ string_replace(local_dfspath, '\\', '/');
+
/* redirect if any component in the path is a link */
pstrcpy(reqpath, localpath);
p = strrchr_m(reqpath, '/');
@@ -402,14 +409,12 @@ static BOOL resolve_dfs_path(TALLOC_CTX *ctx,
if (consumedcntp) {
pstring buf;
- pstrcpy(buf, dfspath);
- trim_char(buf, '\0', '\\');
+ pstrcpy(buf, local_dfspath);
+ trim_char(buf, '\0', '/');
for (; consumed_level; consumed_level--) {
- char *q, *q1, *q2;
- /* Either '\\' or '/' may be a separator. */
- q1 = strrchr_m(buf, '\\');
- q2 = strrchr_m(buf, '/');
- q = MAX(q1,q2);
+ char *q;
+ /* We made sure only '/' may be a separator above. */
+ q = strrchr_m(buf, '/');
if (q) {
*q = 0;
}