From: Jeremy Allison Date: Wed, 23 Jun 2021 06:39:41 +0000 (-0700) Subject: s3: smbd: On startup file_name_hash() can be called with an absolute pathname. X-Git-Tag: tevent-0.11.0~200 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bd0bad6f58ab9aff789392ba1a8e817d7bdca5c8;p=thirdparty%2Fsamba.git 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 Reviewed-by: Ralph Boehme --- diff --git a/source3/smbd/files.c b/source3/smbd/files.c index 6180ff17eab..85ee0b91b37 100644 --- a/source3/smbd/files.c +++ b/source3/smbd/files.c @@ -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; }