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

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