[PATCH] Fix several memory and resource leaks

Jeremy Allison jra at samba.org
Tue Aug 14 17:02:29 UTC 2018


On Tue, Aug 14, 2018 at 06:57:41PM +0200, Andreas Schneider wrote:
> On Monday, 13 August 2018 19:29:39 CEST Jeremy Allison wrote:
> > On Mon, Aug 13, 2018 at 02:20:15PM +0200, Andreas Schneider wrote:
> > > On Sunday, 12 August 2018 15:40:21 CEST Volker Lendecke wrote:
> > > > On Fri, Aug 10, 2018 at 04:36:43PM +0200, Andreas Schneider wrote:
> > > > > I would keep the patch as it is, but would add an additional patch for
> > > > > master which uses a talloc_strackframe(). This would mean we rewrite
> > > > > the
> > > > > code and pass a talloc memory context to parse_nss_parm(). Then we
> > > > > just
> > > > > need one TALLOC_FREE(frame) before we leave.
> > > > 
> > > > Just push it as you like it with my RB+.
> > > > 
> > > > Sorry for the noise,
> > > > 
> > > > Volker
> > 
> > LGTM Andreas, thanks for the fixup !
> 
> Ouch, I've introduced a NULL pointer deref :-(
> 
> The attached patch fixes it.

Thank goodness for Coverity :-). Sorry for missing that.

RB+ and pushed.

> Andreas Schneider                      asn at samba.org
> Samba Team                             www.samba.org
> GPG-ID:     8DFF53E18F2ABC8D8F3C92237EE0FC4DCC014E3D

> From 30734ed3c3c26f3f3fc2f38bf7827a246122cf13 Mon Sep 17 00:00:00 2001
> From: Andreas Schneider <asn at samba.org>
> Date: Tue, 14 Aug 2018 18:55:33 +0200
> Subject: [PATCH] s3:libads: Free addr before we free the context
> 
> Introduced by dbdbd4875ecac3e7334750f46f1f494b7afe6628
> 
> CID 1438395
> 
> BUG: https://bugzilla.samba.org/show_bug.cgi?id=13567
> 
> Signed-off-by: Andreas Schneider <asn at samba.org>
> ---
>  source3/libads/krb5_setpw.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/source3/libads/krb5_setpw.c b/source3/libads/krb5_setpw.c
> index 0418fec5ad3..8f9098853b9 100644
> --- a/source3/libads/krb5_setpw.c
> +++ b/source3/libads/krb5_setpw.c
> @@ -222,9 +222,9 @@ static ADS_STATUS ads_krb5_chg_password(const char *kdc_host,
>      /* We have to obtain an INITIAL changepw ticket for changing password */
>      if (asprintf(&chpw_princ, "kadmin/changepw@%s", realm) == -1) {
>  	krb5_get_init_creds_opt_free(context, opts);
> +	smb_krb5_free_addresses(context, addr);
>  	krb5_free_context(context);
>  	free(realm);
> -	smb_krb5_free_addresses(context, addr);
>  	DEBUG(1,("ads_krb5_chg_password: asprintf fail\n"));
>  	return ADS_ERROR_NT(NT_STATUS_NO_MEMORY);
>      }
> -- 
> 2.18.0
> 




More information about the samba-technical mailing list