]> git.ipfire.org Git - ipfire-2.x.git/blame - src/patches/dnsmasq/0002-crash-at-startup-when-an-empty-suffix-is-supplied-to.patch
dnsmasq: Import more upstream fixes
[ipfire-2.x.git] / src / patches / dnsmasq / 0002-crash-at-startup-when-an-empty-suffix-is-supplied-to.patch
CommitLineData
6644c1c7
MT
1From 00cd9d551998307225312fd21f761cfa8868bd2c Mon Sep 17 00:00:00 2001
2From: Simon Kelley <simon@thekelleys.org.uk>
3Date: Thu, 2 Oct 2014 21:44:21 +0100
5f206778 4Subject: [PATCH 02/87] crash at startup when an empty suffix is supplied to
6644c1c7
MT
5 --conf-dir
6
7---
8 CHANGELOG | 6 ++++++
9 src/option.c | 38 +++++++++++++++++++++++---------------
10 2 files changed, 29 insertions(+), 15 deletions(-)
11
12diff --git a/CHANGELOG b/CHANGELOG
13index 768e2aaca42a..13ab41c05fc3 100644
14--- a/CHANGELOG
15+++ b/CHANGELOG
16@@ -1,3 +1,9 @@
17+version 2.73
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.
21+
22+
23 version 2.72
24 Add ra-advrouter mode, for RFC-3775 mobile IPv6 support.
25
26diff --git a/src/option.c b/src/option.c
27index 45d8875fb7f9..b08e98e16f84 100644
28--- a/src/option.c
29+++ b/src/option.c
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)
32 {
33 comma = split(arg);
34- li = opt_malloc(sizeof(struct list));
35- if (*arg == '*')
36+ if (strlen(arg) != 0)
37 {
38- li->next = match_suffix;
39- match_suffix = li;
40- /* Have to copy: buffer is overwritten */
41- li->suffix = opt_string_alloc(arg+1);
42- }
43- else
44- {
45- li->next = ignore_suffix;
46- ignore_suffix = li;
47- /* Have to copy: buffer is overwritten */
48- li->suffix = opt_string_alloc(arg);
49+ li = opt_malloc(sizeof(struct list));
50+ if (*arg == '*')
51+ {
52+ li->next = match_suffix;
53+ match_suffix = li;
54+ /* Have to copy: buffer is overwritten */
55+ li->suffix = opt_string_alloc(arg+1);
56+ }
57+ else
58+ {
59+ li->next = ignore_suffix;
60+ ignore_suffix = li;
61+ /* Have to copy: buffer is overwritten */
62+ li->suffix = opt_string_alloc(arg);
63+ }
64 }
65- };
66+ }
67
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);
72 free(ignore_suffix);
73 }
74-
75+ for(; match_suffix; match_suffix = li)
76+ {
77+ li = match_suffix->next;
78+ free(match_suffix->suffix);
79+ free(match_suffix);
80+ }
81 break;
82 }
83
84--
852.1.0
86