s3: smbd: Move check_fsp_open() and check_fsp() to smb1_reply.c
authorJeremy Allison <jra@samba.org>
Tue, 10 Jan 2023 01:33:14 +0000 (17:33 -0800)
committerVolker Lendecke <vl@samba.org>
Wed, 11 Jan 2023 08:17:04 +0000 (08:17 +0000)
As these functions can implicitly call reply_nterror(..., NT_STATUS_INVALID_HANDLE)
they should never be available to SMB2 code paths.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Wed Jan 11 08:17:04 UTC 2023 on sn-devel-184

source3/smbd/smb1_reply.c
source3/smbd/smb2_reply.c

index 1ae07f8602f6dbcdcb46fbdb31cc168787a2c359..de6b4d99f79beb478bf07fb4f0afeaa732fe6797 100644 (file)
 #include "source3/printing/rap_jobid.h"
 #include "source3/lib/substitute.h"
 
+/****************************************************************************
+ Check if we have a correct fsp pointing to a file. Basic check for open fsp.
+****************************************************************************/
+
+bool check_fsp_open(connection_struct *conn, struct smb_request *req,
+                    files_struct *fsp)
+{
+       if ((fsp == NULL) || (conn == NULL)) {
+               reply_nterror(req, NT_STATUS_INVALID_HANDLE);
+               return false;
+       }
+       if ((conn != fsp->conn) || (req->vuid != fsp->vuid)) {
+               reply_nterror(req, NT_STATUS_INVALID_HANDLE);
+               return false;
+       }
+       return true;
+}
+
+/****************************************************************************
+ Check if we have a correct fsp pointing to a file.
+****************************************************************************/
+
+bool check_fsp(connection_struct *conn, struct smb_request *req,
+               files_struct *fsp)
+{
+       if (!check_fsp_open(conn, req, fsp)) {
+               return false;
+       }
+       if (fsp->fsp_flags.is_directory) {
+               reply_nterror(req, NT_STATUS_INVALID_DEVICE_REQUEST);
+               return false;
+       }
+       if (fsp_get_pathref_fd(fsp) == -1) {
+               reply_nterror(req, NT_STATUS_ACCESS_DENIED);
+               return false;
+       }
+       fsp->num_smb_operations++;
+       return true;
+}
+
 /****************************************************************************
  Reply to a tcon.
  conn POINTER CAN BE NULL HERE !
index 8b2eca20cb1b5b8c5b2c0c2de839dfc97f909d39..76e3cf789cda8c54d2f37d3104276fdb051a2738 100644 (file)
@@ -524,46 +524,6 @@ size_t srvstr_pull_req_talloc(TALLOC_CTX *ctx, struct smb_request *req,
                                  bufrem, flags);
 }
 
-/****************************************************************************
- Check if we have a correct fsp pointing to a file. Basic check for open fsp.
-****************************************************************************/
-
-bool check_fsp_open(connection_struct *conn, struct smb_request *req,
-                   files_struct *fsp)
-{
-       if ((fsp == NULL) || (conn == NULL)) {
-               reply_nterror(req, NT_STATUS_INVALID_HANDLE);
-               return False;
-       }
-       if ((conn != fsp->conn) || (req->vuid != fsp->vuid)) {
-               reply_nterror(req, NT_STATUS_INVALID_HANDLE);
-               return False;
-       }
-       return True;
-}
-
-/****************************************************************************
- Check if we have a correct fsp pointing to a file.
-****************************************************************************/
-
-bool check_fsp(connection_struct *conn, struct smb_request *req,
-              files_struct *fsp)
-{
-       if (!check_fsp_open(conn, req, fsp)) {
-               return False;
-       }
-       if (fsp->fsp_flags.is_directory) {
-               reply_nterror(req, NT_STATUS_INVALID_DEVICE_REQUEST);
-               return False;
-       }
-       if (fsp_get_pathref_fd(fsp) == -1) {
-               reply_nterror(req, NT_STATUS_ACCESS_DENIED);
-               return False;
-       }
-       fsp->num_smb_operations++;
-       return True;
-}
-
 /****************************************************************************
  Check if we have a correct fsp pointing to a quota fake file. Replacement for
  the CHECK_NTQUOTA_HANDLE_OK macro.