summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2013-03-19 12:36:52 -0700
committerJeremy Allison <jra@samba.org>2013-04-19 14:10:55 -0700
commit63739440f128229a6a99d0653562d3735ae909fb (patch)
treef9249910a103381968b4d1ba61f138e5baa51e20 /source3
parenta36d7633bd3608b71f610fc9df2ad9c66bfdd9c6 (diff)
downloadsamba-63739440f128229a6a99d0653562d3735ae909fb.tar.gz
samba-63739440f128229a6a99d0653562d3735ae909fb.tar.bz2
samba-63739440f128229a6a99d0653562d3735ae909fb.zip
Allow smbd_smb2_request_error_ex() to cope with unread bytes on error.
Drain the socket if a RECVFILE write failed. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Stefan (metze) Metzmacher <metze@samba.org>
Diffstat (limited to 'source3')
-rw-r--r--source3/smbd/smb2_server.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/source3/smbd/smb2_server.c b/source3/smbd/smb2_server.c
index eb7059ed9b..7eb62fcfb3 100644
--- a/source3/smbd/smb2_server.c
+++ b/source3/smbd/smb2_server.c
@@ -2621,11 +2621,21 @@ NTSTATUS smbd_smb2_request_error_ex(struct smbd_smb2_request *req,
{
DATA_BLOB body;
uint8_t *outhdr = SMBD_SMB2_OUT_HDR_PTR(req);
+ size_t unread_bytes = smbd_smb2_unread_bytes(req);
DEBUG(10,("smbd_smb2_request_error_ex: idx[%d] status[%s] |%s| at %s\n",
req->current_idx, nt_errstr(status), info ? " +info" : "",
location));
+ if (unread_bytes) {
+ /* Recvfile error. Drain incoming socket. */
+ size_t ret = drain_socket(req->sconn->sock, unread_bytes);
+ if (ret != unread_bytes) {
+ smbd_server_connection_terminate(req->sconn,
+ "Failed to drain SMB2 socket\n");
+ }
+ }
+
body.data = outhdr + SMB2_HDR_BODY;
body.length = 8;
SSVAL(body.data, 0, 9);