]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: smbd: On startup file_name_hash() can be called with an absolute pathname.
authorJeremy Allison <jra@samba.org>
Wed, 23 Jun 2021 06:39:41 +0000 (23:39 -0700)
committerRalph Boehme <slow@samba.org>
Fri, 25 Jun 2021 15:53:31 +0000 (15:53 +0000)
This occurs on first CHDIR to the root of the share.
Ensure we don't add conn->connectpath twice when doing
creating the file name hash.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/smbd/files.c

index 6180ff17eab3aae9918bee815009615524c12958..85ee0b91b3786afafe753d811494e3e4ecde2bd8 100644 (file)
@@ -1361,8 +1361,19 @@ NTSTATUS file_name_hash(connection_struct *conn,
 
        /* Set the hash of the full pathname. */
 
-       len = full_path_tos(conn->connectpath, name, tmpbuf, sizeof(tmpbuf),
-                           &fullpath, &to_free);
+       if (name[0] == '/') {
+               strlcpy(tmpbuf, name, sizeof(tmpbuf));
+               fullpath = tmpbuf;
+               len = strlen(fullpath);
+               to_free = NULL;
+       } else {
+               len = full_path_tos(conn->connectpath,
+                                   name,
+                                   tmpbuf,
+                                   sizeof(tmpbuf),
+                                   &fullpath,
+                                   &to_free);
+       }
        if (len == -1) {
                return NT_STATUS_NO_MEMORY;
        }