[Pkg-samba-maint] [samba] 112/135: s3:smb2_server: fix drain_socket error handling

Ivo De Decker ivodd at moszumanska.debian.org
Sat Jan 11 21:30:30 UTC 2014


This is an automated email from the git hooks/post-receive script.

ivodd pushed a commit to branch master
in repository samba.

commit dc552665b8e41594c4832fe39feda39204d9129c
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Oct 14 16:42:55 2013 +0200

    s3:smb2_server: fix drain_socket error handling
    
    smbd_smb2_request_error_ex() should return NTSTATUS and the caller
    will terminate the connection.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: David Disseldorp <ddiss at samba.org>
    (cherry picked from commit 9393e28df59954414313bfae70ffb796d3e332fe)
---
 source3/smbd/smb2_server.c | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/source3/smbd/smb2_server.c b/source3/smbd/smb2_server.c
index b031c6d..1918460 100644
--- a/source3/smbd/smb2_server.c
+++ b/source3/smbd/smb2_server.c
@@ -2644,10 +2644,24 @@ NTSTATUS smbd_smb2_request_error_ex(struct smbd_smb2_request *req,
 
 	if (unread_bytes) {
 		/* Recvfile error. Drain incoming socket. */
-		size_t ret = drain_socket(req->sconn->sock, unread_bytes);
+		size_t ret;
+
+		errno = 0;
+		ret = drain_socket(req->sconn->sock, unread_bytes);
 		if (ret != unread_bytes) {
-			smbd_server_connection_terminate(req->sconn,
-				"Failed to drain SMB2 socket\n");
+			NTSTATUS error;
+
+			if (errno == 0) {
+				error = NT_STATUS_IO_DEVICE_ERROR;
+			} else {
+				error = map_nt_error_from_unix_common(errno);
+			}
+
+			DEBUG(2, ("Failed to drain %u bytes from SMB2 socket: "
+				  "ret[%u] errno[%d] => %s\n",
+				  (unsigned)unread_bytes,
+				  (unsigned)ret, errno, nt_errstr(error)));
+			return error;
 		}
 	}
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-samba/samba.git




More information about the Pkg-samba-maint mailing list