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