From 02e0ba710db5f1819fb53161d1ddcdac8e01bb6c Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 15 Apr 2021 10:23:37 +0200 Subject: [PATCH] smb2_server: remove state->hdr.done and always set state->vector first Signed-off-by: Stefan Metzmacher Reviewed-by: Jeremy Allison --- source3/smbd/globals.h | 1 - source3/smbd/smb2_server.c | 14 ++++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/source3/smbd/globals.h b/source3/smbd/globals.h index d071dc4c23b..db79d548035 100644 --- a/source3/smbd/globals.h +++ b/source3/smbd/globals.h @@ -460,7 +460,6 @@ struct smbXsrv_connection { struct smbd_smb2_request *req; struct { uint8_t nbt[NBT_HDR_SIZE]; - bool done; } hdr; struct iovec vector; struct msghdr msg; diff --git a/source3/smbd/smb2_server.c b/source3/smbd/smb2_server.c index b0a475ec8c1..9a3cc8447ba 100644 --- a/source3/smbd/smb2_server.c +++ b/source3/smbd/smb2_server.c @@ -4589,6 +4589,10 @@ static NTSTATUS smbd_smb2_request_next_incoming(struct smbXsrv_connection *xconn *state = (struct smbd_smb2_request_read_state) { .req = req, .min_recv_size = lp_min_receive_file_size(), + .vector = (struct iovec) { + .iov_base = (void *)state->hdr.nbt, + .iov_len = NBT_HDR_SIZE, + }, }; TEVENT_FD_READABLE(xconn->transport.fde); @@ -4915,12 +4919,6 @@ static NTSTATUS smbd_smb2_io_handler(struct smbXsrv_connection *xconn, } again: - if (!state->hdr.done) { - state->hdr.done = true; - - state->vector.iov_base = (void *)state->hdr.nbt; - state->vector.iov_len = NBT_HDR_SIZE; - } state->msg = (struct msghdr) { .msg_iov = &state->vector, @@ -5053,6 +5051,10 @@ got_full: *state = (struct smbd_smb2_request_read_state) { .req = req, .min_recv_size = lp_min_receive_file_size(), + .vector = (struct iovec) { + .iov_base = (void *)state->hdr.nbt, + .iov_len = NBT_HDR_SIZE, + }, }; req = NULL; goto again; -- 2.47.3