Blame SOURCES/autofs-5.1.0-fix-leak-in-parse_mount.patch

306fa1
autofs-5.1.0 - fix leak in parse_mount()
306fa1
306fa1
From: Ian Kent <ikent@redhat.com>
306fa1
306fa1
Fix a potential memory leak of the allocated mount location
306fa1
in modules/parse_sun.c:parse_mount().
306fa1
---
306fa1
 CHANGELOG           |    1 +
306fa1
 modules/parse_sun.c |    8 ++++++--
306fa1
 2 files changed, 7 insertions(+), 2 deletions(-)
306fa1
306fa1
--- autofs-5.0.7.orig/CHANGELOG
306fa1
+++ autofs-5.0.7/CHANGELOG
306fa1
@@ -144,6 +144,7 @@
306fa1
 - check options length before use in parse_amd.c.
306fa1
 - fix some out of order evaluations in parse_amd.c.
306fa1
 - fix copy and paste error in dup_defaults_entry().
306fa1
+- fix leak in parse_mount().
306fa1
 
306fa1
 25/07/2012 autofs-5.0.7
306fa1
 =======================
306fa1
--- autofs-5.0.7.orig/modules/parse_sun.c
306fa1
+++ autofs-5.0.7/modules/parse_sun.c
306fa1
@@ -1567,7 +1567,10 @@ int parse_mount(struct autofs_point *ap,
306fa1
 		 */
306fa1
 		if ((strstr(options, "fstype=autofs") &&
306fa1
 		     strstr(options, "hosts"))) {
306fa1
-			loc = NULL;
306fa1
+			if (loc) {
306fa1
+				free(loc);
306fa1
+				loc = NULL;
306fa1
+			}
306fa1
 			loclen = 0;
306fa1
 		} else {
306fa1
 			loclen = strlen(loc);
306fa1
@@ -1591,7 +1594,8 @@ int parse_mount(struct autofs_point *ap,
306fa1
 			rv = sun_mount(ap, ap->path, name, name_len,
306fa1
 				       loc, loclen, options, ctxt);
306fa1
 
306fa1
-		free(loc);
306fa1
+		if (loc)
306fa1
+			free(loc);
306fa1
 		free(options);
306fa1
 		pthread_setcancelstate(cur_state, NULL);
306fa1
 	}