Blame SOURCES/nfs-utils-2.3.3-gssd-memoryleak.patch

6f21ac
diff --git a/utils/gssd/krb5_util.c b/utils/gssd/krb5_util.c
6f21ac
index eb993aab..26e51edf 100644
6f21ac
--- a/utils/gssd/krb5_util.c
6f21ac
+++ b/utils/gssd/krb5_util.c
6f21ac
@@ -459,7 +459,7 @@ gssd_get_single_krb5_cred(krb5_context context,
6f21ac
 	if (ccache)
6f21ac
 		krb5_cc_close(context, ccache);
6f21ac
 	krb5_free_cred_contents(context, &my_creds);
6f21ac
-	free(k5err);
6f21ac
+	krb5_free_string(context, k5err);
6f21ac
 	return (code);
6f21ac
 }
6f21ac
 
6f21ac
@@ -698,7 +698,7 @@ gssd_search_krb5_keytab(krb5_context context, krb5_keytab kt,
6f21ac
 				 "we failed to unparse principal name: %s\n",
6f21ac
 				 k5err);
6f21ac
 			k5_free_kt_entry(context, kte);
6f21ac
-			free(k5err);
6f21ac
+			krb5_free_string(context, k5err);
6f21ac
 			k5err = NULL;
6f21ac
 			continue;
6f21ac
 		}
6f21ac
@@ -745,7 +745,7 @@ gssd_search_krb5_keytab(krb5_context context, krb5_keytab kt,
6f21ac
 	if (retval < 0)
6f21ac
 		retval = 0;
6f21ac
   out:
6f21ac
-	free(k5err);
6f21ac
+	krb5_free_string(context, k5err);
6f21ac
 	return retval;
6f21ac
 }
6f21ac
 
6f21ac
@@ -774,7 +774,7 @@ find_keytab_entry(krb5_context context, krb5_keytab kt,
6f21ac
 	int tried_all = 0, tried_default = 0, tried_upper = 0;
6f21ac
 	krb5_principal princ;
6f21ac
 	const char *notsetstr = "not set";
6f21ac
-	char *adhostoverride;
6f21ac
+	char *adhostoverride = NULL;
6f21ac
 
6f21ac
 
6f21ac
 	/* Get full target hostname */
6f21ac
@@ -802,7 +802,6 @@ find_keytab_entry(krb5_context context, krb5_keytab kt,
6f21ac
 				adhostoverride);
6f21ac
 	        /* No overflow: Windows cannot handle strings longer than 19 chars */
6f21ac
 	        strcpy(myhostad, adhostoverride);
6f21ac
-		free(adhostoverride);
6f21ac
 	} else {
6f21ac
 	        strcpy(myhostad, myhostname);
6f21ac
 	        for (i = 0; myhostad[i] != 0; ++i) {
6f21ac
@@ -811,6 +810,8 @@ find_keytab_entry(krb5_context context, krb5_keytab kt,
6f21ac
 	        myhostad[i] = '$';
6f21ac
 	        myhostad[i+1] = 0;
6f21ac
 	}
6f21ac
+	if (adhostoverride)
6f21ac
+		krb5_free_string(context, adhostoverride);
6f21ac
 
6f21ac
 	if (!srchost) {
6f21ac
 		retval = get_full_hostname(myhostname, myhostname, sizeof(myhostname));
6f21ac
@@ -901,7 +902,7 @@ find_keytab_entry(krb5_context context, krb5_keytab kt,
6f21ac
 				k5err = gssd_k5_err_msg(context, code);
6f21ac
 				printerr(1, "%s while building principal for '%s'\n",
6f21ac
 					 k5err, spn);
6f21ac
-				free(k5err);
6f21ac
+				krb5_free_string(context, k5err);
6f21ac
 				k5err = NULL;
6f21ac
 				continue;
6f21ac
 			}
6f21ac
@@ -911,7 +912,7 @@ find_keytab_entry(krb5_context context, krb5_keytab kt,
6f21ac
 				k5err = gssd_k5_err_msg(context, code);
6f21ac
 				printerr(3, "%s while getting keytab entry for '%s'\n",
6f21ac
 					 k5err, spn);
6f21ac
-				free(k5err);
6f21ac
+				krb5_free_string(context, k5err);
6f21ac
 				k5err = NULL;
6f21ac
 				/*
6f21ac
 				 * We tried the active directory machine account
6f21ac
@@ -960,7 +961,7 @@ out:
6f21ac
 		k5_free_default_realm(context, default_realm);
6f21ac
 	if (realmnames)
6f21ac
 		krb5_free_host_realm(context, realmnames);
6f21ac
-	free(k5err);
6f21ac
+	krb5_free_string(context, k5err);
6f21ac
 	return retval;
6f21ac
 }
6f21ac
 
6f21ac
@@ -1223,7 +1224,7 @@ gssd_destroy_krb5_machine_creds(void)
6f21ac
 			printerr(0, "WARNING: %s while resolving credential "
6f21ac
 				    "cache '%s' for destruction\n", k5err,
6f21ac
 				    ple->ccname);
6f21ac
-			free(k5err);
6f21ac
+			krb5_free_string(context, k5err);
6f21ac
 			k5err = NULL;
6f21ac
 			continue;
6f21ac
 		}
6f21ac
@@ -1232,13 +1233,13 @@ gssd_destroy_krb5_machine_creds(void)
6f21ac
 			k5err = gssd_k5_err_msg(context, code);
6f21ac
 			printerr(0, "WARNING: %s while destroying credential "
6f21ac
 				    "cache '%s'\n", k5err, ple->ccname);
6f21ac
-			free(k5err);
6f21ac
+			krb5_free_string(context, k5err);
6f21ac
 			k5err = NULL;
6f21ac
 		}
6f21ac
 	}
6f21ac
 	krb5_free_context(context);
6f21ac
   out:
6f21ac
-	free(k5err);
6f21ac
+	krb5_free_string(context, k5err);
6f21ac
 }
6f21ac
 
6f21ac
 /*
6f21ac
@@ -1321,7 +1322,7 @@ out_free_kt:
6f21ac
 out_free_context:
6f21ac
 	krb5_free_context(context);
6f21ac
 out:
6f21ac
-	free(k5err);
6f21ac
+	krb5_free_string(context, k5err);
6f21ac
 	return retval;
6f21ac
 }
6f21ac