[PATCHES] fix a couple of memory leaks

Uri Simchoni uri at samba.org
Sun Jul 3 20:23:59 UTC 2016


Hi,

Attached are fixes to a couple of memory leaks. Found by Valgrind by
running "net ads testjoin", but since they are both in connection
establishment code paths, the memory is also probably leaked by winbindd.

Review & push appreciated.

Thanks,
Uri.
-------------- next part --------------
From a8fc653b77218bdc2ce3d7ece9ad4419380d5268 Mon Sep 17 00:00:00 2001
From: Uri Simchoni <uri at samba.org>
Date: Sun, 3 Jul 2016 22:50:22 +0300
Subject: [PATCH 1/2] auth: fix a memory leak in gssapi_get_session_key()

BUG: https://bugzilla.samba.org/show_bug.cgi?id=12006

Signed-off-by: Uri Simchoni <uri at samba.org>
---
 auth/kerberos/gssapi_pac.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/auth/kerberos/gssapi_pac.c b/auth/kerberos/gssapi_pac.c
index 685d0ec..7ae22f5 100644
--- a/auth/kerberos/gssapi_pac.c
+++ b/auth/kerberos/gssapi_pac.c
@@ -257,11 +257,8 @@ NTSTATUS gssapi_get_session_key(TALLOC_CTX *mem_ctx,
 				*keytype = KRB5_KEY_TYPE(subkey);
 				krb5_free_keyblock(NULL /* should be krb5_context */, subkey);
 			} else
-#else
-			{
-				*keytype = 0;
-			}
 #endif
+				*keytype = 0;
 			gss_maj = gss_release_buffer_set(&gss_min, &set);
 	
 			return NT_STATUS_OK;
-- 
2.5.5


From df9cbb5a6d2946e1f0afb1c4dfb9237427578f80 Mon Sep 17 00:00:00 2001
From: Uri Simchoni <uri at samba.org>
Date: Sun, 3 Jul 2016 22:51:56 +0300
Subject: [PATCH 2/2] s3-libads: fix a memory leak in ads_sasl_spnego_bind()

BUG: https://bugzilla.samba.org/show_bug.cgi?id=12006

Signed-off-by: Uri Simchoni <uri at samba.org>
---
 source3/libads/sasl.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/source3/libads/sasl.c b/source3/libads/sasl.c
index 10f63e8..d76d872 100644
--- a/source3/libads/sasl.c
+++ b/source3/libads/sasl.c
@@ -696,7 +696,7 @@ static ADS_STATUS ads_sasl_spnego_bind(ADS_STRUCT *ads)
 	struct berval *scred=NULL;
 	int rc, i;
 	ADS_STATUS status;
-	DATA_BLOB blob;
+	DATA_BLOB blob = data_blob_null;
 	char *given_principal = NULL;
 	char *OIDs[ASN1_MAX_OIDS];
 #ifdef HAVE_KRB5
@@ -792,6 +792,9 @@ static ADS_STATUS ads_sasl_spnego_bind(ADS_STRUCT *ads)
 done:
 	ads_free_service_principal(&p);
 	TALLOC_FREE(frame);
+	if (blob.data != NULL) {
+		data_blob_free(&blob);
+	}
 	return status;
 }
 
-- 
2.5.5



More information about the samba-technical mailing list