1 From 00cd9d551998307225312fd21f761cfa8868bd2c Mon Sep 17 00:00:00 2001
2 From: Simon Kelley <simon@thekelleys.org.uk>
3 Date: Thu, 2 Oct 2014 21:44:21 +0100
4 Subject: [PATCH 02/87] crash at startup when an empty suffix is supplied to
9 src/option.c | 38 +++++++++++++++++++++++---------------
10 2 files changed, 29 insertions(+), 15 deletions(-)
12 diff --git a/CHANGELOG b/CHANGELOG
13 index 768e2aaca42a..13ab41c05fc3 100644
18 + Fix crash at startup when an empty suffix is supplied to
19 + --conf-dir, also trivial memory leak. Thanks to
20 + Tomas Hozza for spotting this.
24 Add ra-advrouter mode, for RFC-3775 mobile IPv6 support.
26 diff --git a/src/option.c b/src/option.c
27 index 45d8875fb7f9..b08e98e16f84 100644
30 @@ -1474,22 +1474,25 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
31 for (arg = comma; arg; arg = comma)
34 - li = opt_malloc(sizeof(struct list));
36 + if (strlen(arg) != 0)
38 - li->next = match_suffix;
40 - /* Have to copy: buffer is overwritten */
41 - li->suffix = opt_string_alloc(arg+1);
45 - li->next = ignore_suffix;
47 - /* Have to copy: buffer is overwritten */
48 - li->suffix = opt_string_alloc(arg);
49 + li = opt_malloc(sizeof(struct list));
52 + li->next = match_suffix;
54 + /* Have to copy: buffer is overwritten */
55 + li->suffix = opt_string_alloc(arg+1);
59 + li->next = ignore_suffix;
61 + /* Have to copy: buffer is overwritten */
62 + li->suffix = opt_string_alloc(arg);
68 if (!(dir_stream = opendir(directory)))
69 die(_("cannot access directory %s: %s"), directory, EC_FILE);
70 @@ -1555,7 +1558,12 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
71 free(ignore_suffix->suffix);
75 + for(; match_suffix; match_suffix = li)
77 + li = match_suffix->next;
78 + free(match_suffix->suffix);