From e5b669b89a80d9af1d40ef34f7663d4184eb7dd0 Mon Sep 17 00:00:00 2001 From: renmingshuai Date: Wed, 22 Nov 2023 15:14:43 +0800 Subject: [PATCH] Fix memory leak when using --dhcp-optsfile with DHCPv6 options (cherry picked from commit 7294f8f794e140ddbc38f63dc5fd16c4ebaf9a1a) --- ...when-using-dhcp-optsfile-with-DHCPv6.patch | 48 +++++++++++++++++++ dnsmasq.spec | 9 +++- 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 backport-Fix-memory-leak-when-using-dhcp-optsfile-with-DHCPv6.patch diff --git a/backport-Fix-memory-leak-when-using-dhcp-optsfile-with-DHCPv6.patch b/backport-Fix-memory-leak-when-using-dhcp-optsfile-with-DHCPv6.patch new file mode 100644 index 0000000..a18c50a --- /dev/null +++ b/backport-Fix-memory-leak-when-using-dhcp-optsfile-with-DHCPv6.patch @@ -0,0 +1,48 @@ +From d16b995756dc079b1fdc2e63665793979f766a26 Mon Sep 17 00:00:00 2001 +From: renmingshuai +Date: Sat, 30 Sep 2023 23:31:08 +0100 +Subject: [PATCH] Fix memory leak when using --dhcp-optsfile with DHCPv6 + options. + +Conflict:NA +Reference:https://thekelleys.org.uk/gitweb/?p=dnsmasq.git;a=commit;h=d16b995756dc079b1fdc2e63665793979f766a26 +--- + src/option.c | 12 ++++++++++-- + 1 file changed, 10 insertions(+), 2 deletions(-) + +diff --git a/src/option.c b/src/option.c +index 8322725..286f06b 100644 +--- a/src/option.c ++++ b/src/option.c +@@ -5734,11 +5734,11 @@ static void clear_dynamic_conf(void) + } + } + +-static void clear_dynamic_opt(void) ++static void clear_dhcp_opt(struct dhcp_opt **dhcp_opts) + { + struct dhcp_opt *opts, *cp, **up; + +- for (up = &daemon->dhcp_opts, opts = daemon->dhcp_opts; opts; opts = cp) ++ for (up = dhcp_opts, opts = *dhcp_opts; opts; opts = cp) + { + cp = opts->next; + +@@ -5752,6 +5752,14 @@ static void clear_dynamic_opt(void) + } + } + ++static void clear_dynamic_opt(void) ++{ ++ clear_dhcp_opt(&daemon->dhcp_opts); ++#ifdef HAVE_DHCP6 ++ clear_dhcp_opt(&daemon->dhcp_opts6); ++#endif ++} ++ + void reread_dhcp(void) + { + struct hostsfile *hf; +-- +2.23.0 + diff --git a/dnsmasq.spec b/dnsmasq.spec index b272976..b9a8c4c 100644 --- a/dnsmasq.spec +++ b/dnsmasq.spec @@ -1,6 +1,6 @@ Name: dnsmasq Version: 2.86 -Release: 6 +Release: 7 Summary: Dnsmasq provides network infrastructure for small networks License: GPLv2 or GPLv3 URL: http://www.thekelleys.org.uk/dnsmasq/ @@ -46,6 +46,7 @@ Patch35: backport-Handle-DS-records-for-unsupported-crypto-algorithms-.pa Patch36: backport-Optimize-inserting-records-into-server-list.patch Patch37: backport-Fix-massive-confusion-on-server-reload.patch Patch38: backport-Fix-use-after-free-in-mark_servers.patch +Patch39: backport-Fix-memory-leak-when-using-dhcp-optsfile-with-DHCPv6.patch BuildRequires: gcc BuildRequires: dbus-devel pkgconfig libidn2-devel nettle-devel systemd @@ -135,6 +136,12 @@ install -Dpm644 %{SOURCE2} $RPM_BUILD_ROOT%{_sysusersdir}/dnsmasq.conf %{_mandir}/man8/dnsmasq* %changelog +* Wed Nov 22 2023 renmingshuai - 2.86-7 +- Type:bugfix +- Id:NA +- SUG:NA +- DESC:Fix memory leak when using --dhcp-optsfile with DHCPv6 options + * Thu Apr 27 2023 yanglu - 2.86-6 - Type:bugfix - Id:NA -- Gitee