diff options
author | Alice Mitchell <ajmitchell@redhat.com> | 2021-08-21 13:44:09 -0400 |
---|---|---|
committer | Steve Dickson <steved@redhat.com> | 2021-08-21 14:02:56 -0400 |
commit | e1ba9f52c965aa632ce1289b16dbaf0f65fc1a21 (patch) | |
tree | c12e5f7c1c822d103ee8627c1ef3130432d5eb96 /utils | |
parent | 8d8f2792eb266a42ecf40ed5473af6a24f0d3bdf (diff) | |
download | nfs-utils-e1ba9f52c965aa632ce1289b16dbaf0f65fc1a21.tar.gz |
nfs-utils: Fix mem leaks in krb5_util
query_krb5_ccache: if the ret_realm strdup fails then ret_princname leaks
gssd_get_krb5_machine_cred_list: l was being leaked if the realloc failed
it was also leaked if the strdup of ccname failed
Signed-off-by: Alice Mitchell <ajmitchell@redhat.com>
Signed-off-by: Steve Dickson <steved@redhat.com>
Diffstat (limited to 'utils')
-rw-r--r-- | utils/gssd/krb5_util.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/utils/gssd/krb5_util.c b/utils/gssd/krb5_util.c index c5f1152e..6d059f33 100644 --- a/utils/gssd/krb5_util.c +++ b/utils/gssd/krb5_util.c @@ -1129,6 +1129,12 @@ query_krb5_ccache(const char* cred_cache, char **ret_princname, *str = '\0'; *ret_princname = strdup(princstring); *ret_realm = strdup(str+1); + if (!*ret_princname || !*ret_realm) { + free(*ret_princname); + free(*ret_realm); + *ret_princname = NULL; + *ret_realm = NULL; + } } k5_free_unparsed_name(context, princstring); } @@ -1350,15 +1356,19 @@ gssd_get_krb5_machine_cred_list(char ***list) if (retval) continue; if (i + 1 > listsize) { + char **tmplist; listsize += listinc; - l = (char **) + tmplist = (char **) realloc(l, listsize * sizeof(char *)); - if (l == NULL) { + if (tmplist == NULL) { + gssd_free_krb5_machine_cred_list(l); retval = ENOMEM; goto out_lock; } + l = tmplist; } if ((l[i++] = strdup(ple->ccname)) == NULL) { + gssd_free_krb5_machine_cred_list(l); retval = ENOMEM; goto out_lock; } |