]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
vfs_xattr_tdb: fix dangling symlink detection
authorRalph Boehme <slow@samba.org>
Fri, 15 Aug 2025 09:50:26 +0000 (11:50 +0200)
committerVolker Lendecke <vl@samba.org>
Fri, 15 Aug 2025 14:36:34 +0000 (14:36 +0000)
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 <slow@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
source3/modules/vfs_xattr_tdb.c

index 447d868924d1042d7b93f45a271b3c2984ff81a5..19331d0de4f63d00a750a67591e58ad7f057fca2 100644 (file)
@@ -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;
                        }
                }
        }