summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Kelley <simon@thekelleys.org.uk>2014-10-02 21:44:21 +0100
committerSimon Kelley <simon@thekelleys.org.uk>2014-10-02 21:44:21 +0100
commit00cd9d551998307225312fd21f761cfa8868bd2c (patch)
tree04407b65a04ca37747f23803b74a7f1e3ee17c01
parentf2658275b25ebfe691cdcb9fede85a3088cca168 (diff)
downloaddnsmasq-00cd9d551998307225312fd21f761cfa8868bd2c.tar.gz
crash at startup when an empty suffix is supplied to --conf-dir
-rw-r--r--CHANGELOG6
-rw-r--r--src/option.c38
2 files changed, 29 insertions, 15 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 768e2aa..13ab41c 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,9 @@
+version 2.73
+ Fix crash at startup when an empty suffix is supplied to
+ --conf-dir, also trivial memory leak. Thanks to
+ Tomas Hozza for spotting this.
+
+
version 2.72
Add ra-advrouter mode, for RFC-3775 mobile IPv6 support.
diff --git a/src/option.c b/src/option.c
index 45d8875..b08e98e 100644
--- a/src/option.c
+++ b/src/option.c
@@ -1474,22 +1474,25 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
for (arg = comma; arg; arg = comma)
{
comma = split(arg);
- li = opt_malloc(sizeof(struct list));
- if (*arg == '*')
+ if (strlen(arg) != 0)
{
- li->next = match_suffix;
- match_suffix = li;
- /* Have to copy: buffer is overwritten */
- li->suffix = opt_string_alloc(arg+1);
- }
- else
- {
- li->next = ignore_suffix;
- ignore_suffix = li;
- /* Have to copy: buffer is overwritten */
- li->suffix = opt_string_alloc(arg);
+ li = opt_malloc(sizeof(struct list));
+ if (*arg == '*')
+ {
+ li->next = match_suffix;
+ match_suffix = li;
+ /* Have to copy: buffer is overwritten */
+ li->suffix = opt_string_alloc(arg+1);
+ }
+ else
+ {
+ li->next = ignore_suffix;
+ ignore_suffix = li;
+ /* Have to copy: buffer is overwritten */
+ li->suffix = opt_string_alloc(arg);
+ }
}
- };
+ }
if (!(dir_stream = opendir(directory)))
die(_("cannot access directory %s: %s"), directory, EC_FILE);
@@ -1555,7 +1558,12 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
free(ignore_suffix->suffix);
free(ignore_suffix);
}
-
+ for(; match_suffix; match_suffix = li)
+ {
+ li = match_suffix->next;
+ free(match_suffix->suffix);
+ free(match_suffix);
+ }
break;
}