Blame SOURCES/autofs-5.1.0-fix-FILE-pointer-check-in-defaults_read_config.patch

304803
autofs-5.1.0 - fix FILE pointer check in defaults_read_config()
304803
304803
From: Ian Kent <raven@themaw.net>
304803
304803
Fix possible use after free usage of FILE pointer in defaults_read_config().
304803
---
304803
 CHANGELOG      |    1 +
304803
 lib/defaults.c |   15 +++++++--------
304803
 2 files changed, 8 insertions(+), 8 deletions(-)
304803
304803
--- autofs-5.0.7.orig/CHANGELOG
304803
+++ autofs-5.0.7/CHANGELOG
304803
@@ -132,6 +132,7 @@
304803
 - fix race accessing qdn in get_query_dn().
304803
 - fix leak in cache_push_mapent().
304803
 - fix config entry read buffer not checked.
304803
+- fix FILE pointer check in defaults_read_config().
304803
 
304803
 25/07/2012 autofs-5.0.7
304803
 =======================
304803
--- autofs-5.0.7.orig/lib/defaults.c
304803
+++ autofs-5.0.7/lib/defaults.c
304803
@@ -1055,6 +1055,8 @@ unsigned int defaults_read_config(unsign
304803
 
304803
 	ret = 1;
304803
 
304803
+	conf = oldconf = NULL;
304803
+
304803
 	pthread_mutex_lock(&conf_mutex);
304803
 	if (!config) {
304803
 		if (conf_init()) {
304803
@@ -1081,15 +1083,11 @@ unsigned int defaults_read_config(unsign
304803
 	    stb.st_mtime <= config->modified &&
304803
 	    (oldstat = fstat(fileno(oldconf), &oldstb) == -1) &&
304803
 	    oldstb.st_mtime <= config->modified) {
304803
-		fclose(conf);
304803
-		fclose(oldconf);
304803
 		goto out;
304803
 	}
304803
 
304803
 	if (conf || oldconf) {
304803
 		if (!reset_defaults(to_syslog)) {
304803
-			fclose(conf);
304803
-			fclose(oldconf);
304803
 			ret = 0;
304803
 			goto out;
304803
 		}
304803
@@ -1107,10 +1105,8 @@ unsigned int defaults_read_config(unsign
304803
 		}
304803
 	}
304803
 
304803
-	if (conf) {
304803
+	if (conf)
304803
 		read_config(to_syslog, conf, DEFAULT_CONFIG_FILE);
304803
-		fclose(conf);
304803
-	}
304803
 
304803
 	/*
304803
 	 * Read the old config file and override the installed
304803
@@ -1131,7 +1127,6 @@ unsigned int defaults_read_config(unsign
304803
 			clean_ldap_multi_option(NAME_LDAP_URI);
304803
 
304803
 		read_config(to_syslog, oldconf, OLD_CONFIG_FILE);
304803
-		fclose(oldconf);
304803
 
304803
 		if (ldap_search_base) {
304803
 			co = conf_lookup(sec, NAME_SEARCH_BASE);
304803
@@ -1150,6 +1145,10 @@ unsigned int defaults_read_config(unsign
304803
 		}
304803
 	}
304803
 out:
304803
+	if (conf)
304803
+		fclose(conf);
304803
+	if (oldconf)
304803
+		fclose(oldconf);
304803
 	pthread_mutex_unlock(&conf_mutex);
304803
 	return ret;
304803
 }