Skip to content

Commit

Permalink
Merge pull request #2265 from pi-hole/fix/v5_v6_hosts_cnameRecords
Browse files Browse the repository at this point in the history
Prevent duplicated entries on successive v5 Teleporter importing
  • Loading branch information
DL6ER authored Feb 23, 2025
2 parents 4e66f43 + 7e47e30 commit 22175ec
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/config/dnsmasq_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 22175ec

Please sign in to comment.