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

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