From: Ralph Boehme Date: Tue, 31 Oct 2023 11:10:17 +0000 (+0100) Subject: smbd: in file_set_dosmode() do an early exit if smb_fname->fsp is NULL X-Git-Tag: talloc-2.4.2~851 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b3c6c677a7031ad3a182a90c621a3f1ffb37e9fb;p=thirdparty%2Fsamba.git smbd: in file_set_dosmode() do an early exit if smb_fname->fsp is NULL No change in behaviour. Simplifies coming changes. Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison --- diff --git a/source3/smbd/dosmode.c b/source3/smbd/dosmode.c index 8b51f5a7d8b..f544ef96177 100644 --- a/source3/smbd/dosmode.c +++ b/source3/smbd/dosmode.c @@ -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;