From 7e47e30fa9dfd7718d46ee751e6cc0df8f2f2682 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sun, 23 Feb 2025 20:06:33 +0100 Subject: [PATCH] Wipe out possibly existing entries in dns.hosts, dns.cnameRecords, and dhcp.hosts when importing from a v5 Teleporter file having the corresponding files Signed-off-by: DL6ER --- src/config/dnsmasq_config.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/config/dnsmasq_config.c b/src/config/dnsmasq_config.c index afef19ab9..a6dad4b8e 100644 --- a/src/config/dnsmasq_config.c +++ b/src/config/dnsmasq_config.c @@ -841,6 +841,12 @@ bool read_legacy_dhcp_static_config(void) return false; } + // Clear out config.dhcp.hosts array if it exists + if(config.dhcp.hosts.v.json != NULL) + cJSON_Delete(config.dhcp.hosts.v.json); + config.dhcp.hosts.v.json = cJSON_CreateArray(); + + // Read file line by line char *linebuffer = NULL; size_t size = 0u; errno = 0; @@ -898,6 +904,12 @@ bool read_legacy_cnames_config(void) return false; } + // Clear out config.dns.cnameRecords array if it exists + if(config.dns.cnameRecords.v.json != NULL) + cJSON_Delete(config.dns.cnameRecords.v.json); + config.dns.cnameRecords.v.json = cJSON_CreateArray(); + + // Read file line by line char *linebuffer = NULL; size_t size = 0u; errno = 0; @@ -955,6 +967,12 @@ bool read_legacy_custom_hosts_config(void) return false; } + // Clear out config.dns.hosts array if it exists + if(config.dns.hosts.v.json != NULL) + cJSON_Delete(config.dns.hosts.v.json); + config.dns.hosts.v.json = cJSON_CreateArray(); + + // Read file line by line char *linebuffer = NULL; size_t size = 0u; errno = 0;