* [PATCH - nfs-utils] gssd: don't krb5_free_context if krb5_init_context fails
@ 2013-03-04 21:57 NeilBrown
2013-03-25 14:16 ` Steve Dickson
0 siblings, 1 reply; 2+ messages in thread
From: NeilBrown @ 2013-03-04 21:57 UTC (permalink / raw)
To: Steve Dickson; +Cc: NFS
[-- Attachment #1: Type: text/plain, Size: 1662 bytes --]
Most places that call krb5_init_context() abort cleanly on failure.
However these two then try to free the non-existent context, which
doesn't end well.
Signed-off-by: NeilBrown <neilb@suse.de>
diff --git a/utils/gssd/krb5_util.c b/utils/gssd/krb5_util.c
index aeb8f70..4befa72 100644
--- a/utils/gssd/krb5_util.c
+++ b/utils/gssd/krb5_util.c
@@ -1212,9 +1212,9 @@ gssd_destroy_krb5_machine_creds(void)
"cache '%s'\n", k5err, ple->ccname);
}
}
+ krb5_free_context(context);
out:
free(k5err);
- krb5_free_context(context);
}
/*
@@ -1257,7 +1257,7 @@ gssd_refresh_krb5_machine_credential(char *hostname,
k5err = gssd_k5_err_msg(context, code);
printerr(0, "ERROR: %s: %s while resolving keytab '%s'\n",
__func__, k5err, keytabfile);
- goto out;
+ goto out_free_context;
}
if (ple == NULL) {
@@ -1272,7 +1272,7 @@ gssd_refresh_krb5_machine_credential(char *hostname,
"in keytab %s for connection with host %s\n",
__FUNCTION__, keytabfile, hostname);
retval = code;
- goto out;
+ goto out_free_kt;
}
ple = get_ple_by_princ(context, kte.principal);
@@ -1288,14 +1288,15 @@ gssd_refresh_krb5_machine_credential(char *hostname,
__FUNCTION__, pname ? pname : "<unparsable>",
hostname);
if (pname) k5_free_unparsed_name(context, pname);
- goto out;
+ goto out_free_kt;
}
}
retval = gssd_get_single_krb5_cred(context, kt, ple, 0);
-out:
- if (kt)
- krb5_kt_close(context, kt);
+out_free_kt:
+ krb5_kt_close(context, kt);
+out_free_context:
krb5_free_context(context);
+out:
free(k5err);
return retval;
}
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 828 bytes --]
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH - nfs-utils] gssd: don't krb5_free_context if krb5_init_context fails
2013-03-04 21:57 [PATCH - nfs-utils] gssd: don't krb5_free_context if krb5_init_context fails NeilBrown
@ 2013-03-25 14:16 ` Steve Dickson
0 siblings, 0 replies; 2+ messages in thread
From: Steve Dickson @ 2013-03-25 14:16 UTC (permalink / raw)
To: NeilBrown; +Cc: NFS
On 04/03/13 16:57, NeilBrown wrote:
>
> Most places that call krb5_init_context() abort cleanly on failure.
> However these two then try to free the non-existent context, which
> doesn't end well.
>
> Signed-off-by: NeilBrown <neilb@suse.de>
Committed....
steved.
>
> diff --git a/utils/gssd/krb5_util.c b/utils/gssd/krb5_util.c
> index aeb8f70..4befa72 100644
> --- a/utils/gssd/krb5_util.c
> +++ b/utils/gssd/krb5_util.c
> @@ -1212,9 +1212,9 @@ gssd_destroy_krb5_machine_creds(void)
> "cache '%s'\n", k5err, ple->ccname);
> }
> }
> + krb5_free_context(context);
> out:
> free(k5err);
> - krb5_free_context(context);
> }
>
> /*
> @@ -1257,7 +1257,7 @@ gssd_refresh_krb5_machine_credential(char *hostname,
> k5err = gssd_k5_err_msg(context, code);
> printerr(0, "ERROR: %s: %s while resolving keytab '%s'\n",
> __func__, k5err, keytabfile);
> - goto out;
> + goto out_free_context;
> }
>
> if (ple == NULL) {
> @@ -1272,7 +1272,7 @@ gssd_refresh_krb5_machine_credential(char *hostname,
> "in keytab %s for connection with host %s\n",
> __FUNCTION__, keytabfile, hostname);
> retval = code;
> - goto out;
> + goto out_free_kt;
> }
>
> ple = get_ple_by_princ(context, kte.principal);
> @@ -1288,14 +1288,15 @@ gssd_refresh_krb5_machine_credential(char *hostname,
> __FUNCTION__, pname ? pname : "<unparsable>",
> hostname);
> if (pname) k5_free_unparsed_name(context, pname);
> - goto out;
> + goto out_free_kt;
> }
> }
> retval = gssd_get_single_krb5_cred(context, kt, ple, 0);
> -out:
> - if (kt)
> - krb5_kt_close(context, kt);
> +out_free_kt:
> + krb5_kt_close(context, kt);
> +out_free_context:
> krb5_free_context(context);
> +out:
> free(k5err);
> return retval;
> }
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-03-25 14:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-04 21:57 [PATCH - nfs-utils] gssd: don't krb5_free_context if krb5_init_context fails NeilBrown
2013-03-25 14:16 ` Steve Dickson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).