smbd: in file_set_dosmode() do an early exit if smb_fname->fsp is NULL
authorRalph Boehme <slow@samba.org>
Tue, 31 Oct 2023 11:10:17 +0000 (12:10 +0100)
committerJeremy Allison <jra@samba.org>
Sun, 5 Nov 2023 18:34:38 +0000 (18:34 +0000)
No change in behaviour. Simplifies coming changes.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/dosmode.c

index 8b51f5a7d8b15f15e426f27698fb61f9d8aba766..f544ef96177b12751c25d59417b31b880b470c17 100644 (file)
@@ -920,26 +920,24 @@ int file_set_dosmode(connection_struct *conn,
        DEBUG(10,("file_set_dosmode: setting dos mode 0x%x on file %s\n",
                  dosmode, smb_fname_str_dbg(smb_fname)));
 
+       if (smb_fname->fsp == NULL) {
+               errno = ENOENT;
+               return -1;
+       }
+
        unixmode = smb_fname->st.st_ex_mode;
 
-       if (smb_fname->fsp != NULL) {
-               get_acl_group_bits(
-                       conn, smb_fname->fsp, &smb_fname->st.st_ex_mode);
-       }
+       get_acl_group_bits(conn, smb_fname->fsp, &smb_fname->st.st_ex_mode);
 
        if (S_ISDIR(smb_fname->st.st_ex_mode))
                dosmode |= FILE_ATTRIBUTE_DIRECTORY;
        else
                dosmode &= ~FILE_ATTRIBUTE_DIRECTORY;
 
-       if (smb_fname->fsp != NULL) {
-               /* Store the DOS attributes in an EA by preference. */
-               status = SMB_VFS_FSET_DOS_ATTRIBUTES(
-                       conn, metadata_fsp(smb_fname->fsp), dosmode);
-       } else {
-               status = NT_STATUS_OBJECT_NAME_NOT_FOUND;
-       }
-
+       /* Store the DOS attributes in an EA by preference. */
+       status = SMB_VFS_FSET_DOS_ATTRIBUTES(conn,
+                                            metadata_fsp(smb_fname->fsp),
+                                            dosmode);
        if (NT_STATUS_IS_OK(status)) {
                smb_fname->st.cached_dos_attributes = dosmode;
                ret = 0;