diff options
-rw-r--r-- | source3/smbd/globals.h | 1 | ||||
-rw-r--r-- | source3/smbd/smb2_read.c | 21 | ||||
-rw-r--r-- | source3/smbd/smb2_server.c | 6 |
3 files changed, 20 insertions, 8 deletions
diff --git a/source3/smbd/globals.h b/source3/smbd/globals.h index 8a9af6c531..079976eefb 100644 --- a/source3/smbd/globals.h +++ b/source3/smbd/globals.h @@ -615,6 +615,7 @@ struct smbd_smb2_send_queue { struct smbd_smb2_send_queue *prev, *next; DATA_BLOB *sendfile_header; + NTSTATUS *sendfile_status; struct iovec *vector; int count; diff --git a/source3/smbd/smb2_read.c b/source3/smbd/smb2_read.c index 0d08114a27..470e496631 100644 --- a/source3/smbd/smb2_read.c +++ b/source3/smbd/smb2_read.c @@ -186,6 +186,7 @@ static int smb2_sendfile_send_data(struct smbd_smb2_read_state *state) uint64_t in_offset = state->in_offset; files_struct *fsp = state->fsp; const DATA_BLOB *hdr = state->smb2req->queue_entry.sendfile_header; + NTSTATUS *pstatus = state->smb2req->queue_entry.sendfile_status; struct smbXsrv_connection *xconn = state->smb2req->xconn; ssize_t nread; ssize_t ret; @@ -225,8 +226,8 @@ static int smb2_sendfile_send_data(struct smbd_smb2_read_state *state) "Terminating\n", fsp_str_dbg(fsp), strerror(saved_errno), smbXsrv_connection_dbg(xconn))); - exit_server_cleanly("smb2_sendfile_send_data: " - "fake_sendfile failed"); + *pstatus = map_nt_error_from_unix_common(saved_errno); + return 0; } goto out; } @@ -235,7 +236,8 @@ static int smb2_sendfile_send_data(struct smbd_smb2_read_state *state) "%s (%s) for client %s. Terminating\n", fsp_str_dbg(fsp), strerror(saved_errno), smbXsrv_connection_dbg(xconn))); - exit_server_cleanly("smb2_sendfile_send_data: sendfile failed"); + *pstatus = map_nt_error_from_unix_common(saved_errno); + return 0; } else if (nread == 0) { /* * Some sendfile implementations return 0 to indicate @@ -265,7 +267,8 @@ normal_read: "%s (%s) for client %s. Terminating\n", fsp_str_dbg(fsp), strerror(saved_errno), smbXsrv_connection_dbg(xconn))); - exit_server_cleanly("smb2_sendfile_send_data: write_data failed"); + *pstatus = map_nt_error_from_unix_common(saved_errno); + return 0; } nread = fake_sendfile(xconn, fsp, in_offset, in_length); if (nread == -1) { @@ -275,8 +278,8 @@ normal_read: "Terminating\n", fsp_str_dbg(fsp), strerror(saved_errno), smbXsrv_connection_dbg(xconn))); - exit_server_cleanly("smb2_sendfile_send_data: " - "fake_sendfile failed"); + *pstatus = map_nt_error_from_unix_common(saved_errno); + return 0; } out: @@ -292,8 +295,8 @@ normal_read: __func__, fsp_str_dbg(fsp), strerror(saved_errno), smbXsrv_connection_dbg(xconn))); - exit_server_cleanly("smb2_sendfile_send_data: " - "sendfile_short_send failed"); + *pstatus = map_nt_error_from_unix_common(saved_errno); + return 0; } } @@ -305,6 +308,8 @@ normal_read: &lock); SMB_VFS_STRICT_UNLOCK(fsp->conn, fsp, &lock); + + *pstatus = NT_STATUS_OK; return 0; } diff --git a/source3/smbd/smb2_server.c b/source3/smbd/smb2_server.c index d9e6a7644d..984d4406aa 100644 --- a/source3/smbd/smb2_server.c +++ b/source3/smbd/smb2_server.c @@ -3115,6 +3115,7 @@ static NTSTATUS smbd_smb2_flush_send_queue(struct smbXsrv_connection *xconn) struct smbd_smb2_send_queue *e = xconn->smb2.send_queue; if (e->sendfile_header != NULL) { + NTSTATUS status = NT_STATUS_INTERNAL_ERROR; size_t size = 0; size_t i = 0; uint8_t *buf; @@ -3142,6 +3143,7 @@ static NTSTATUS smbd_smb2_flush_send_queue(struct smbXsrv_connection *xconn) e->sendfile_header->data = buf; e->sendfile_header->length = size; + e->sendfile_status = &status; e->count = 0; xconn->smb2.send_queue_len--; @@ -3151,6 +3153,10 @@ static NTSTATUS smbd_smb2_flush_send_queue(struct smbXsrv_connection *xconn) * the destructor. */ talloc_free(e->mem_ctx); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } continue; } |