Linux-NFS Archive on lore.kernel.org
 help / color / Atom feed
From: Steve Dickson <SteveD@RedHat.com>
To: Linux NFS Mailing list <linux-nfs@vger.kernel.org>
Subject: Re: [PATCH] gssd: Closed a memory leak in find_keytab_entry()
Date: Fri, 14 Feb 2020 16:41:16 -0500
Message-ID: <a256db55-1d40-bf4a-a131-4bdac4bf37f7@RedHat.com> (raw)
In-Reply-To: <20200212190515.7443-1-steved@redhat.com>



On 2/12/20 2:05 PM, Steve Dickson wrote:
> When 'adhostoverride' is "not set", which
> is most of the time, adhostoverride is not freed.
> 
> Signed-off-by: Steve Dickson <steved@redhat.com>
Committed... 

stesved
> ---
>  utils/gssd/krb5_util.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/utils/gssd/krb5_util.c b/utils/gssd/krb5_util.c
> index a1c43d2..85f60ae 100644
> --- a/utils/gssd/krb5_util.c
> +++ b/utils/gssd/krb5_util.c
> @@ -799,7 +799,7 @@ find_keytab_entry(krb5_context context, krb5_keytab kt,
>  	int tried_all = 0, tried_default = 0, tried_upper = 0;
>  	krb5_principal princ;
>  	const char *notsetstr = "not set";
> -	char *adhostoverride;
> +	char *adhostoverride = NULL;
>  
>  
>  	/* Get full target hostname */
> @@ -827,7 +827,6 @@ find_keytab_entry(krb5_context context, krb5_keytab kt,
>  				adhostoverride);
>  	        /* No overflow: Windows cannot handle strings longer than 19 chars */
>  	        strcpy(myhostad, adhostoverride);
> -		free(adhostoverride);
>  	} else {
>  	        strcpy(myhostad, myhostname);
>  	        for (i = 0; myhostad[i] != 0; ++i) {
> @@ -836,6 +835,8 @@ find_keytab_entry(krb5_context context, krb5_keytab kt,
>  	        myhostad[i] = '$';
>  	        myhostad[i+1] = 0;
>  	}
> +	if (adhostoverride)
> +		krb5_free_string(context, adhostoverride);
>  
>  	if (!srchost) {
>  		retval = get_full_hostname(myhostname, myhostname, sizeof(myhostname));
> 


      reply index

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-12 19:05 Steve Dickson
2020-02-14 21:41 ` Steve Dickson [this message]

Reply instructions:

You may reply publically to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a256db55-1d40-bf4a-a131-4bdac4bf37f7@RedHat.com \
    --to=steved@redhat.com \
    --cc=linux-nfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-NFS Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-nfs/0 linux-nfs/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-nfs linux-nfs/ https://lore.kernel.org/linux-nfs \
		linux-nfs@vger.kernel.org
	public-inbox-index linux-nfs

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-nfs


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git