From 9e50e213526990d458a669edca9a65ace6adba39 Mon Sep 17 00:00:00 2001 From: Uri Simchoni Date: Sun, 3 Jul 2016 22:51:56 +0300 Subject: [PATCH 1/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 Reviewed-by: Richard Sharpe Reviewed-by: Andreas Schneider (cherry picked from commit a646d9e796902dcb5246eb585433d4859796be2f) --- 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 From f71e830749b0c8f6687855b1ead24ac046f04850 Mon Sep 17 00:00:00 2001 From: Uri Simchoni Date: Sun, 3 Jul 2016 22:50:22 +0300 Subject: [PATCH 2/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 Reviewed-by: Richard Sharpe Reviewed-by: Andreas Schneider Autobuild-User(master): Richard Sharpe Autobuild-Date(master): Wed Jul 6 00:40:15 CEST 2016 on sn-devel-144 (cherry picked from commit 77f3730295735dc9465c8e3d07fc761c83761b6e) --- auth/kerberos/gssapi_pac.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/auth/kerberos/gssapi_pac.c b/auth/kerberos/gssapi_pac.c index 685d0ec..74c199a 100644 --- a/auth/kerberos/gssapi_pac.c +++ b/auth/kerberos/gssapi_pac.c @@ -246,6 +246,7 @@ NTSTATUS gssapi_get_session_key(TALLOC_CTX *mem_ctx, int diflen, i; const uint8_t *p; + *keytype = 0; if (set->count < 2) { #ifdef HAVE_GSSKRB5_GET_SUBKEY @@ -256,10 +257,6 @@ NTSTATUS gssapi_get_session_key(TALLOC_CTX *mem_ctx, if (gss_maj == 0) { *keytype = KRB5_KEY_TYPE(subkey); krb5_free_keyblock(NULL /* should be krb5_context */, subkey); - } else -#else - { - *keytype = 0; } #endif gss_maj = gss_release_buffer_set(&gss_min, &set); @@ -270,7 +267,6 @@ NTSTATUS gssapi_get_session_key(TALLOC_CTX *mem_ctx, gse_sesskeytype_oid.elements, gse_sesskeytype_oid.length) != 0) { /* Perhaps a non-krb5 session key */ - *keytype = 0; gss_maj = gss_release_buffer_set(&gss_min, &set); return NT_STATUS_OK; } @@ -280,7 +276,6 @@ NTSTATUS gssapi_get_session_key(TALLOC_CTX *mem_ctx, gss_maj = gss_release_buffer_set(&gss_min, &set); return NT_STATUS_INVALID_PARAMETER; } - *keytype = 0; for (i = 0; i < diflen; i++) { *keytype = (*keytype << 7) | (p[i] & 0x7f); if (i + 1 != diflen && (p[i] & 0x80) == 0) { -- 2.5.5