Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 130701790bf2d95e902edf16031ff596 > files > 166

autofs-5.0.1-0.rc2.164.el5_8.src.rpm

diff --git a/CHANGELOG b/CHANGELOG
index 9bebe79..bcd6e5c 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -30,6 +30,7 @@
 - fix macro table locking.
 - fix nsswitch parser locking.
 - allow only one master map read task at a time.
+- fix misc memory leaks.
 
 1/9/2006 autofs-5.0.1 rc2
 -------------------------
diff --git a/daemon/direct.c b/daemon/direct.c
index d2b75f9..c92a745 100644
--- a/daemon/direct.c
+++ b/daemon/direct.c
@@ -887,8 +887,8 @@ void *expire_proc_direct(void *arg)
 	left = 0;
 
 	/* Get a list of real mounts and expire them if possible */
-	pthread_cleanup_push(mnts_cleanup, mnts);
 	mnts = get_mnt_list(_PROC_MOUNTS, "/", 0);
+	pthread_cleanup_push(mnts_cleanup, mnts);
 	for (next = mnts; next; next = next->next) {
 		if (!strcmp(next->fs_type, "autofs")) {
 			/*
diff --git a/daemon/indirect.c b/daemon/indirect.c
index 492cbbb..5b073e4 100644
--- a/daemon/indirect.c
+++ b/daemon/indirect.c
@@ -477,8 +477,8 @@ void *expire_proc_indirect(void *arg)
 	left = 0;
 
 	/* Get a list of real mounts and expire them if possible */
-	pthread_cleanup_push(mnts_cleanup, mnts);
 	mnts = get_mnt_list(_PROC_MOUNTS, ap->path, 0);
+	pthread_cleanup_push(mnts_cleanup, mnts);
 	for (next = mnts; next; next = next->next) {
 		char *ind_key;
 		int ret;
diff --git a/modules/lookup_file.c b/modules/lookup_file.c
index d09afac..a0e22d2 100644
--- a/modules/lookup_file.c
+++ b/modules/lookup_file.c
@@ -192,6 +192,7 @@ static int read_one(FILE *f, char *key, 
 			else {
 				if (key_len == KEY_MAX_LEN) {
 					state = st_badent;
+					gotten = got_nothing;
 					warn(LOGOPT_ANY,
 					      MODPREFIX "map key \"%s...\" "
 					      "is too long.  The maximum key "
@@ -822,8 +823,10 @@ static int lookup_one(struct autofs_poin
 				}
 
 				eq = strncmp(s_key, key, key_len);
-				if (eq != 0)
+				if (eq != 0) {
+					free(s_key);
 					continue;
+				}
 
 				free(s_key);
 
diff --git a/modules/parse_sun.c b/modules/parse_sun.c
index 9f9bf54..9847ea9 100644
--- a/modules/parse_sun.c
+++ b/modules/parse_sun.c
@@ -394,16 +394,11 @@ static char *concat_options(char *left, 
 	char buf[MAX_ERR_BUF];
 	char *ret;
 
-	if (left == NULL || *left == '\0') {
-		free(left);
-		ret = strdup(right);
-		return ret;
-	}
+	if (left == NULL || *left == '\0')
+		return strdup(right);
 
-	if (right == NULL || *right == '\0') {
-		free(right);
+	if (right == NULL || *right == '\0')
 		return strdup(left);
-	}
 
 	ret = malloc(strlen(left) + strlen(right) + 2);
 
@@ -741,6 +736,8 @@ static int parse_mapent(const char *ent,
 				estr = strerror_r(errno, buf, MAX_ERR_BUF);
 				error(logopt, MODPREFIX
 				      "concat_options: %s", estr);
+				if (newopt)
+					free(newopt);
 				free(myoptions);
 				return 0;
 			}
@@ -780,7 +777,7 @@ static int parse_mapent(const char *ent,
 	p = skipspace(p);
 
 	while (*p && *p != '/') {
-		char *ent;
+		char *tmp, *ent;
 
 		/* Location can't begin with a '/' */
 		if (*p == '/') {
@@ -811,14 +808,15 @@ static int parse_mapent(const char *ent,
 
 		debug(logopt, MODPREFIX "dequote(\"%.*s\") -> %s", l, p, ent);
 
-		loc = realloc(loc, strlen(loc) + l + 2);
-		if (!loc) {
+		tmp = realloc(loc, strlen(loc) + l + 2);
+		if (!tmp) {
 			error(logopt, MODPREFIX "out of memory");
 			free(ent);
 			free(myoptions);
 			free(loc);
 			return 0;
 		}
+		loc = tmp;
 
 		strcat(loc, " ");
 		strcat(loc, ent);
@@ -968,17 +966,23 @@ int parse_mount(struct autofs_point *ap,
 		char *mnt_options = NULL;
 
 		do {
-			char *noptions = NULL;
+			char *tmp, *noptions = NULL;
 
 			p = parse_options(p, &noptions, ap->logopt);
-			mnt_options = concat_options(mnt_options, noptions);
-
-			if (mnt_options == NULL) {
+			tmp = concat_options(mnt_options, noptions);
+			if (!tmp) {
 				char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
 				error(ap->logopt,
 				      MODPREFIX "concat_options: %s", estr);
+				if (noptions)
+					free(noptions);
+				if (mnt_options)
+					free(mnt_options);
+				free(options);
 				return 1;
 			}
+			mnt_options = tmp;
+
 			p = skipspace(p);
 		} while (*p == '-');
 
@@ -1232,7 +1236,7 @@ int parse_mount(struct autofs_point *ap,
 		p = skipspace(p);
 
 		while (*p) {
-			char *ent;
+			char *tmp, *ent;
 
 			l = chunklen(p, check_colon(p));
 			ent = dequote(p, l, ap->logopt);
@@ -1255,14 +1259,15 @@ int parse_mount(struct autofs_point *ap,
 			debug(ap->logopt,
 			      MODPREFIX "dequote(\"%.*s\") -> %s", l, p, ent);
 
-			loc = realloc(loc, strlen(loc) + l + 2);
-			if (!loc) {
+			tmp = realloc(loc, strlen(loc) + l + 2);
+			if (!tmp) {
 				free(ent);
 				free(loc);
 				free(options);
 				error(ap->logopt, MODPREFIX "out of memory");
 				return 1;
 			}
+			loc = tmp;
 
 			strcat(loc, " ");
 			strcat(loc, ent);