1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-26 10:04:02 +03:00

s3: smbd: On startup file_name_hash() can be called with an absolute pathname.

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>
This commit is contained in:
Jeremy Allison 2021-06-22 23:39:41 -07:00 committed by Ralph Boehme
parent a6df051dd5
commit bd0bad6f58

View 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;
}