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

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