diff mbox series

[13/19] Removed resource leaks from gssd/krb5_util.c

Message ID 20190508133536.6077-14-steved@redhat.com (mailing list archive)
State New, archived
Headers show
Series Covertity Scan: Removed resources leaks | expand

Commit Message

Steve Dickson May 8, 2019, 1:35 p.m. UTC
gssd/krb5_util.c:696: overwrite_var: Overwriting "k5err" in
	"k5err = gssd_k5_err_msg(context, code)" leaks
	the storage that "k5err" points to.

gssd/krb5_util.c:737: overwrite_var: Overwriting "k5err" in
	"k5err = gssd_k5_err_msg(context, code)" leaks
	the storage that "k5err" points to.

gssd/krb5_util.c:899: overwrite_var: Overwriting "k5err" in
	"k5err = gssd_k5_err_msg(context, code)" leaks
	the storage that "k5err" points to.

krb5_util.c:1173: leaked_storage: Variable "l" going out
	of scope leaks the storage it points to.

Signed-off-by: Steve Dickson <steved@redhat.com>
---
 utils/gssd/krb5_util.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/utils/gssd/krb5_util.c b/utils/gssd/krb5_util.c
index 6daba44..454a6eb 100644
--- a/utils/gssd/krb5_util.c
+++ b/utils/gssd/krb5_util.c
@@ -699,6 +699,8 @@  gssd_search_krb5_keytab(krb5_context context, krb5_keytab kt,
 				 "we failed to unparse principal name: %s\n",
 				 k5err);
 			k5_free_kt_entry(context, kte);
+			free(k5err);
+			k5err = NULL;
 			continue;
 		}
 		printerr(4, "Processing keytab entry for principal '%s'\n",
@@ -900,6 +902,8 @@  find_keytab_entry(krb5_context context, krb5_keytab kt,
 				k5err = gssd_k5_err_msg(context, code);
 				printerr(1, "%s while building principal for '%s'\n",
 					 k5err, spn);
+				free(k5err);
+				k5err = NULL;
 				continue;
 			}
 			code = krb5_kt_get_entry(context, kt, princ, 0, 0, kte);
@@ -1169,7 +1173,8 @@  gssd_get_krb5_machine_cred_list(char ***list)
 		*list = l;
 		retval = 0;
 		goto out;
-	}
+	} else
+		free((void *)l);
   out:
 	return retval;
 }
@@ -1217,6 +1222,8 @@  gssd_destroy_krb5_machine_creds(void)
 			printerr(0, "WARNING: %s while resolving credential "
 				    "cache '%s' for destruction\n", k5err,
 				    ple->ccname);
+			free(k5err);
+			k5err = NULL;
 			continue;
 		}