From: Ralph Boehme Date: Fri, 15 Aug 2025 09:50:26 +0000 (+0200) Subject: vfs_xattr_tdb: fix dangling symlink detection X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0ec18e6bc39595af2b25fe566c1ee140e02a6592;p=thirdparty%2Fsamba.git vfs_xattr_tdb: fix dangling symlink detection The caller might not have called stat on smb_fname. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15843 Signed-off-by: Ralph Boehme Reviewed-by: Volker Lendecke (cherry picked from commit 2e88ba4b4de146327c19682d59bbe34d68158bf7) --- diff --git a/source3/modules/vfs_xattr_tdb.c b/source3/modules/vfs_xattr_tdb.c index 447d868924d..19331d0de4f 100644 --- a/source3/modules/vfs_xattr_tdb.c +++ b/source3/modules/vfs_xattr_tdb.c @@ -604,13 +604,12 @@ static int xattr_tdb_unlinkat(vfs_handle_struct *handle, } else { ret = SMB_VFS_NEXT_STAT(handle, full_fname); if (ret == -1 && (errno == ENOENT || errno == ELOOP)) { - if (VALID_STAT(smb_fname->st) && - S_ISLNK(smb_fname->st.st_ex_mode)) { - /* - * Original name was a link - Could be - * trying to remove a dangling symlink. - */ - ret = SMB_VFS_NEXT_LSTAT(handle, full_fname); + /* + * Could be trying to remove a dangling symlink. + */ + ret = SMB_VFS_NEXT_LSTAT(handle, full_fname); + if (ret == 0 && !S_ISLNK(full_fname->st.st_ex_mode)) { + ret = -1; } } }