|
|
591f3a |
autofs-5.1.7 - fix concat_options() error handling
|
|
|
591f3a |
|
|
|
591f3a |
From: Ian Kent <raven@themaw.net>
|
|
|
591f3a |
|
|
|
591f3a |
There's a possibility of a memory leak in the mount options processing
|
|
|
591f3a |
when calling concat_options() in parse_mount() of the Sun format map
|
|
|
591f3a |
entry parsing.
|
|
|
591f3a |
|
|
|
591f3a |
There's also a case in do_init() of the Sun map format parsing where
|
|
|
591f3a |
a previously freed value is used in a logging statement without being
|
|
|
591f3a |
set to MULL.
|
|
|
591f3a |
|
|
|
591f3a |
So ensure concat_options() always frees it's arguments so that the
|
|
|
591f3a |
handling can be consistent in all places.
|
|
|
591f3a |
|
|
|
591f3a |
Signed-off-by: Ian Kent <raven@themaw.net>
|
|
|
591f3a |
---
|
|
|
591f3a |
CHANGELOG | 1 +
|
|
|
591f3a |
modules/parse_sun.c | 24 +++++++++++-------------
|
|
|
591f3a |
2 files changed, 12 insertions(+), 13 deletions(-)
|
|
|
591f3a |
|
|
|
591f3a |
--- autofs-5.1.4.orig/CHANGELOG
|
|
|
591f3a |
+++ autofs-5.1.4/CHANGELOG
|
|
|
591f3a |
@@ -102,6 +102,7 @@
|
|
|
591f3a |
- fix hosts map deadlock on restart.
|
|
|
591f3a |
- fix deadlock with hosts map reload.
|
|
|
591f3a |
- fix memory leak in update_hosts_mounts().
|
|
|
591f3a |
+- fix concat_options() error handling.
|
|
|
591f3a |
|
|
|
591f3a |
xx/xx/2018 autofs-5.1.5
|
|
|
591f3a |
- fix flag file permission.
|
|
|
591f3a |
--- autofs-5.1.4.orig/modules/parse_sun.c
|
|
|
591f3a |
+++ autofs-5.1.4/modules/parse_sun.c
|
|
|
591f3a |
@@ -380,7 +380,8 @@ static int do_init(int argc, const char
|
|
|
591f3a |
if (!tmp) {
|
|
|
591f3a |
char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
|
|
|
591f3a |
logerr(MODPREFIX "concat_options: %s", estr);
|
|
|
591f3a |
- free(gbl_options);
|
|
|
591f3a |
+ /* freed in concat_options */
|
|
|
591f3a |
+ ctxt->optstr = NULL;
|
|
|
591f3a |
} else
|
|
|
591f3a |
ctxt->optstr = tmp;
|
|
|
591f3a |
} else {
|
|
|
591f3a |
@@ -492,12 +493,16 @@ static char *concat_options(char *left,
|
|
|
591f3a |
char *ret;
|
|
|
591f3a |
|
|
|
591f3a |
if (left == NULL || *left == '\0') {
|
|
|
591f3a |
+ if (!right || *right == '\0')
|
|
|
591f3a |
+ return NULL;
|
|
|
591f3a |
ret = strdup(right);
|
|
|
591f3a |
free(right);
|
|
|
591f3a |
return ret;
|
|
|
591f3a |
}
|
|
|
591f3a |
|
|
|
591f3a |
if (right == NULL || *right == '\0') {
|
|
|
591f3a |
+ if (left == NULL || *left == '\0')
|
|
|
591f3a |
+ return NULL;
|
|
|
591f3a |
ret = strdup(left);
|
|
|
591f3a |
free(left);
|
|
|
591f3a |
return ret;
|
|
|
591f3a |
@@ -508,6 +513,8 @@ static char *concat_options(char *left,
|
|
|
591f3a |
if (ret == NULL) {
|
|
|
591f3a |
char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
|
|
|
591f3a |
logerr(MODPREFIX "malloc: %s", estr);
|
|
|
591f3a |
+ free(left);
|
|
|
591f3a |
+ free(right);
|
|
|
591f3a |
return NULL;
|
|
|
591f3a |
}
|
|
|
591f3a |
|
|
|
591f3a |
@@ -988,14 +995,13 @@ static int parse_mapent(const char *ent,
|
|
|
591f3a |
if (newopt && strstr(newopt, myoptions)) {
|
|
|
591f3a |
free(myoptions);
|
|
|
591f3a |
myoptions = newopt;
|
|
|
591f3a |
- } else {
|
|
|
591f3a |
+ } else if (newopt) {
|
|
|
591f3a |
tmp = concat_options(myoptions, newopt);
|
|
|
591f3a |
if (!tmp) {
|
|
|
591f3a |
char *estr;
|
|
|
591f3a |
estr = strerror_r(errno, buf, MAX_ERR_BUF);
|
|
|
591f3a |
error(logopt, MODPREFIX
|
|
|
591f3a |
"concat_options: %s", estr);
|
|
|
591f3a |
- free(myoptions);
|
|
|
591f3a |
return 0;
|
|
|
591f3a |
}
|
|
|
591f3a |
myoptions = tmp;
|
|
|
591f3a |
@@ -1363,16 +1369,12 @@ dont_expand:
|
|
|
591f3a |
if (mnt_options && noptions && strstr(noptions, mnt_options)) {
|
|
|
591f3a |
free(mnt_options);
|
|
|
591f3a |
mnt_options = noptions;
|
|
|
591f3a |
- } else {
|
|
|
591f3a |
+ } else if (noptions) {
|
|
|
591f3a |
tmp = concat_options(mnt_options, noptions);
|
|
|
591f3a |
if (!tmp) {
|
|
|
591f3a |
char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
|
|
|
591f3a |
error(ap->logopt,
|
|
|
591f3a |
MODPREFIX "concat_options: %s", estr);
|
|
|
591f3a |
- if (noptions)
|
|
|
591f3a |
- free(noptions);
|
|
|
591f3a |
- if (mnt_options)
|
|
|
591f3a |
- free(mnt_options);
|
|
|
591f3a |
free(options);
|
|
|
591f3a |
free(pmapent);
|
|
|
591f3a |
return 1;
|
|
|
591f3a |
@@ -1392,15 +1394,11 @@ dont_expand:
|
|
|
591f3a |
if (options && mnt_options && strstr(mnt_options, options)) {
|
|
|
591f3a |
free(options);
|
|
|
591f3a |
options = mnt_options;
|
|
|
591f3a |
- } else {
|
|
|
591f3a |
+ } else if (mnt_options) {
|
|
|
591f3a |
tmp = concat_options(options, mnt_options);
|
|
|
591f3a |
if (!tmp) {
|
|
|
591f3a |
char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
|
|
|
591f3a |
error(ap->logopt, MODPREFIX "concat_options: %s", estr);
|
|
|
591f3a |
- if (options)
|
|
|
591f3a |
- free(options);
|
|
|
591f3a |
- if (mnt_options)
|
|
|
591f3a |
- free(mnt_options);
|
|
|
591f3a |
free(pmapent);
|
|
|
591f3a |
return 1;
|
|
|
591f3a |
}
|