From: Ralph Boehme Date: Mon, 5 Oct 2020 05:51:50 +0000 (+0200) Subject: smbd: use fsp_get_pathref_fd() for logical fd comparisons X-Git-Tag: samba-4.14.0rc1~411 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=61628adef65eefe21efc358f886af28f68e8c0ce;p=thirdparty%2Fsamba.git smbd: use fsp_get_pathref_fd() for logical fd comparisons Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison --- diff --git a/source3/smbd/files.c b/source3/smbd/files.c index 02d3b060552..7a5afa2f082 100644 --- a/source3/smbd/files.c +++ b/source3/smbd/files.c @@ -386,7 +386,7 @@ files_struct *file_find_fd(struct smbd_server_connection *sconn, int fd) files_struct *fsp; for (fsp=sconn->files; fsp; fsp=fsp->next,count++) { - if (fsp->fh->fd == fd) { + if (fsp_get_pathref_fd(fsp) == fd) { if (count > 10) { DLIST_PROMOTE(sconn->files, fsp); } @@ -419,7 +419,7 @@ files_struct *file_find_dif(struct smbd_server_connection *sconn, DLIST_PROMOTE(sconn->files, fsp); } /* Paranoia check. */ - if ((fsp->fh->fd == -1) && + if ((fsp_get_pathref_fd(fsp) == -1) && (fsp->oplock_type != NO_OPLOCK && fsp->oplock_type != LEASE_OPLOCK)) { struct file_id_buf idbuf; diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index 0c6778bda76..a7bbccbd5b2 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -420,7 +420,7 @@ bool check_fsp(connection_struct *conn, struct smb_request *req, reply_nterror(req, NT_STATUS_INVALID_DEVICE_REQUEST); return False; } - if (fsp->fh->fd == -1) { + if (fsp_get_pathref_fd(fsp) == -1) { reply_nterror(req, NT_STATUS_ACCESS_DENIED); return False; } diff --git a/source3/smbd/smb1_utils.c b/source3/smbd/smb1_utils.c index 25a178007dc..d4655ff638f 100644 --- a/source3/smbd/smb1_utils.c +++ b/source3/smbd/smb1_utils.c @@ -64,7 +64,7 @@ struct files_struct *fcb_or_dos_open( fsp->fh->private_options, fsp->access_mask); - if (fsp->fh->fd != -1 && + if (fsp_get_pathref_fd(fsp) != -1 && fsp->vuid == req->vuid && fsp->file_pid == req->smbpid && (fsp->fh->private_options & diff --git a/source3/torture/cmd_vfs.c b/source3/torture/cmd_vfs.c index cae2042ae72..cf2c4984a22 100644 --- a/source3/torture/cmd_vfs.c +++ b/source3/torture/cmd_vfs.c @@ -446,8 +446,8 @@ static NTSTATUS cmd_open(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, c fsp->sent_oplock_break = NO_BREAK_SENT; fsp->fsp_flags.is_directory = false; - vfs->files[fsp->fh->fd] = fsp; - printf("open: fd=%d\n", fsp->fh->fd); + vfs->files[fsp_get_pathref_fd(fsp)] = fsp; + printf("open: fd=%d\n", fsp_get_pathref_fd(fsp)); return NT_STATUS_OK; }