]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Simplify sending oplock_break_message
authorVolker Lendecke <vl@samba.org>
Mon, 29 Apr 2024 09:38:18 +0000 (11:38 +0200)
committerJeremy Allison <jra@samba.org>
Tue, 30 Apr 2024 22:44:32 +0000 (22:44 +0000)
This is fixed length of 33 bytes, no need to talloc

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/open.c
source3/smbd/smb2_oplock.c

index 16950eb414432e1105743520c7f33a8064036e66..9008b82d76312048e7bf6fdd57c0bd5f9ebe4e0f 100644 (file)
@@ -1995,7 +1995,8 @@ NTSTATUS send_break_message(struct messaging_context *msg_ctx,
                .break_to = break_to,
        };
        enum ndr_err_code ndr_err;
-       DATA_BLOB blob;
+       uint8_t msgbuf[33];
+       DATA_BLOB blob = {.data = msgbuf, .length = sizeof(msgbuf)};
        NTSTATUS status;
 
        if (DEBUGLVL(10)) {
@@ -2005,9 +2006,8 @@ NTSTATUS send_break_message(struct messaging_context *msg_ctx,
                NDR_PRINT_DEBUG(oplock_break_message, &msg);
        }
 
-       ndr_err = ndr_push_struct_blob(
+       ndr_err = ndr_push_struct_into_fixed_blob(
                &blob,
-               talloc_tos(),
                &msg,
                (ndr_push_flags_fn_t)ndr_push_oplock_break_message);
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
@@ -2016,9 +2016,10 @@ NTSTATUS send_break_message(struct messaging_context *msg_ctx,
                return ndr_map_error2ntstatus(ndr_err);
        }
 
-       status = messaging_send(
-               msg_ctx, exclusive->pid, MSG_SMB_BREAK_REQUEST, &blob);
-       TALLOC_FREE(blob.data);
+       status = messaging_send(msg_ctx,
+                               exclusive->pid,
+                               MSG_SMB_BREAK_REQUEST,
+                               &blob);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(3, ("Could not send oplock break message: %s\n",
                          nt_errstr(status)));
index 9d61bc2ff63631496205e5797b3c4f8873916110..eec805f1b4658e4d6ac297650f4aeaf9bd94467c 100644 (file)
@@ -829,7 +829,7 @@ static void process_oplock_break_message(struct messaging_context *msg_ctx,
                                         struct server_id src,
                                         DATA_BLOB *data)
 {
-       struct oplock_break_message *msg = NULL;
+       struct oplock_break_message msg;
        enum ndr_err_code ndr_err;
        files_struct *fsp;
        bool use_kernel;
@@ -844,34 +844,22 @@ static void process_oplock_break_message(struct messaging_context *msg_ctx,
 
        smb_vfs_assert_allowed();
 
-       msg = talloc(talloc_tos(), struct oplock_break_message);
-       if (msg == NULL) {
-               DBG_WARNING("talloc failed\n");
-               return;
-       }
-
-       ndr_err = ndr_pull_struct_blob_all(
-               data,
-               msg,
-               msg,
-               (ndr_pull_flags_fn_t)ndr_pull_oplock_break_message);
+       ndr_err = ndr_pull_struct_blob_all_noalloc(
+               data, &msg, (ndr_pull_flags_fn_t)ndr_pull_oplock_break_message);
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                DBG_DEBUG("ndr_pull_oplock_break_message failed: %s\n",
                          ndr_errstr(ndr_err));
-               TALLOC_FREE(msg);
                return;
        }
        if (DEBUGLEVEL >= 10) {
                struct server_id_buf buf;
                DBG_DEBUG("Got break message from %s\n",
                          server_id_str_buf(src, &buf));
-               NDR_PRINT_DEBUG(oplock_break_message, msg);
+               NDR_PRINT_DEBUG(oplock_break_message, &msg);
        }
 
-       break_to = msg->break_to;
-       fsp = initial_break_processing(sconn, msg->id, msg->share_file_id);
-
-       TALLOC_FREE(msg);
+       break_to = msg.break_to;
+       fsp = initial_break_processing(sconn, msg.id, msg.share_file_id);
 
        if (fsp == NULL) {
                /* We hit a race here. Break messages are sent, and before we