[PATCHES] fix a couple of memory leaks

Richard Sharpe realrichardsharpe at gmail.com
Mon Jul 4 02:14:32 UTC 2016


On Sun, Jul 3, 2016 at 1:23 PM, Uri Simchoni <uri at samba.org> wrote:
> 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.

This bit looks quite ugly:

@@ -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_contex
t */, subkey);
  } else
-#else
- {
- *keytype = 0;
- }
 #endif
+ *keytype = 0;
  gss_maj = gss_release_buffer_set(&gss_min, &set);

  return NT_STATUS_OK;

Could be hoist the *keytype = 0 to before the #ifdef? Something like this?

diff --git a/auth/kerberos/gssapi_pac.c b/auth/kerberos/gssapi_pac.c
index 685d0ec..0d0b4ee 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,11 +257,7 @@ 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);

That seems to simplify the #ifdef stuff ...

-- 
Regards,
Richard Sharpe
(何以解憂?唯有杜康。--曹操)



More information about the samba-technical mailing list