s3: smbd: Make sure we do not pass paths with ./ on the front to VFS routines.
authorRichard Sharpe <rsharpe@samba.org>
Wed, 15 Apr 2015 20:53:09 +0000 (13:53 -0700)
committerJeremy Allison <jra@samba.org>
Thu, 16 Apr 2015 05:30:30 +0000 (07:30 +0200)
Signed-off-by: Richard Sharpe <rsharpe@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Thu Apr 16 07:30:30 CEST 2015 on sn-devel-104

source3/smbd/dir.c

index 073ac2fc2ad68a5bc27ebb3f352394da735f24c2..3cddc4ad1010353772fcf8288538a38d41ef7a2c 100644 (file)
@@ -1068,6 +1068,7 @@ bool smbd_dirptr_get_entry(TALLOC_CTX *ctx,
        connection_struct *conn = dirptr->conn;
        size_t slashlen;
        size_t pathlen;
+       bool dirptr_path_is_dot = ISDOT(dirptr->path);
 
        *_smb_fname = NULL;
        *_mode = 0;
@@ -1132,10 +1133,18 @@ bool smbd_dirptr_get_entry(TALLOC_CTX *ctx,
                        return false;
                }
 
-               memcpy(pathreal, dirptr->path, pathlen);
-               pathreal[pathlen] = '/';
-               memcpy(pathreal + slashlen + pathlen, dname,
-                      talloc_get_size(dname));
+               /*
+                * We don't want to pass ./xxx to modules below us so don't
+                * add the path if it is just . by itself.
+                */
+               if (dirptr_path_is_dot) {
+                       memcpy(pathreal, dname, talloc_get_size(dname));
+               } else {
+                       memcpy(pathreal, dirptr->path, pathlen);
+                       pathreal[pathlen] = '/';
+                       memcpy(pathreal + slashlen + pathlen, dname,
+                              talloc_get_size(dname));
+               }
 
                /* Create smb_fname with NULL stream_name. */
                smb_fname = (struct smb_filename) {