From a8716afce8819a6dd8e73b34c513f7f512b274d6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 20 May 2007 08:43:03 +0000 Subject: r23018: fixed a memory leak in our server side session setup code for failed session setups (This used to be commit a4e043e1f8f3cf1ab86e6dde501722b8050bbde4) --- source4/smb_server/smb/sesssetup.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'source4') diff --git a/source4/smb_server/smb/sesssetup.c b/source4/smb_server/smb/sesssetup.c index b6bddaa5b1..56d9e64e31 100644 --- a/source4/smb_server/smb/sesssetup.c +++ b/source4/smb_server/smb/sesssetup.c @@ -60,7 +60,7 @@ static void sesssetup_old_send(struct auth_check_password_request *areq, union smb_sesssetup *sess = talloc_get_type(req->io_ptr, union smb_sesssetup); struct auth_serversupplied_info *server_info = NULL; struct auth_session_info *session_info; - struct smbsrv_session *smb_sess; + struct smbsrv_session *smb_sess = NULL; NTSTATUS status; status = auth_check_password_recv(areq, req, &server_info); @@ -88,6 +88,10 @@ static void sesssetup_old_send(struct auth_check_password_request *areq, sess->old.out.vuid = smb_sess->vuid; failed: + if (!NT_STATUS_IS_OK(status)) { + talloc_free(smb_sess); + req->session = NULL; + } status = auth_nt_status_squash(status); smbsrv_sesssetup_backend_send(req, sess, status); } @@ -155,7 +159,7 @@ static void sesssetup_nt1_send(struct auth_check_password_request *areq, union smb_sesssetup *sess = talloc_get_type(req->io_ptr, union smb_sesssetup); struct auth_serversupplied_info *server_info = NULL; struct auth_session_info *session_info; - struct smbsrv_session *smb_sess; + struct smbsrv_session *smb_sess = NULL; NTSTATUS status; status = auth_check_password_recv(areq, req, &server_info); @@ -204,6 +208,10 @@ static void sesssetup_nt1_send(struct auth_check_password_request *areq, done: status = NT_STATUS_OK; failed: + if (!NT_STATUS_IS_OK(status)) { + talloc_free(smb_sess); + req->session = NULL; + } status = auth_nt_status_squash(status); smbsrv_sesssetup_backend_send(req, sess, status); } @@ -337,6 +345,10 @@ static void sesssetup_spnego_send(struct gensec_update_request *greq, void *priv done: sess->spnego.out.vuid = smb_sess->vuid; failed: + if (!NT_STATUS_IS_OK(status)) { + talloc_free(smb_sess); + req->session = NULL; + } status = auth_nt_status_squash(status); smbsrv_sesssetup_backend_send(req, sess, status); } -- cgit