1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

smbd: Fix the turning an absolute symlink into a relative one

If dirfsp is the share root, we end up with a "/." at the end of
subdir_path. subdir_of() does not cover that case. fsp_fullbasepath()
takes care of that case and also avoids a talloc.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
This commit is contained in:
Volker Lendecke 2024-02-04 11:45:22 +01:00 committed by Ralph Boehme
parent 259517d7ae
commit 0d8b71f0b6

View File

@ -808,18 +808,13 @@ NTSTATUS read_symlink_reparse(TALLOC_CTX *mem_ctx,
}
if (lnk->substitute_name[0] == '/') {
char *subdir_path = NULL;
size_t len = fsp_fullbasepath(dirfsp, NULL, 0);
char subdir_path[len + 1];
char *abs_target_canon = NULL;
const char *relative = NULL;
bool in_share;
subdir_path = talloc_asprintf(talloc_tos(),
"%s/%s",
dirfsp->conn->connectpath,
dirfsp->fsp_name->base_name);
if (subdir_path == NULL) {
goto nomem;
}
fsp_fullbasepath(dirfsp, subdir_path, sizeof(subdir_path));
abs_target_canon = canonicalize_absolute_path(
talloc_tos(), lnk->substitute_name);
@ -828,7 +823,7 @@ NTSTATUS read_symlink_reparse(TALLOC_CTX *mem_ctx,
}
in_share = subdir_of(subdir_path,
strlen(subdir_path),
len,
abs_target_canon,
&relative);
if (in_share) {