Skip to content

Commit

Permalink
Fix crash when reloading DHCP config on SIGHUP.
Browse files Browse the repository at this point in the history
Confusion in the code to free old DHCP configuration when it's
being reloaded causes invalid pointers to be followed and a crash.

https://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/2024q4/017764.html

has a more complete explanation of the problem.

Signed-off-by: DL6ER <[email protected]>
  • Loading branch information
simonkelley authored and DL6ER committed Oct 4, 2024
1 parent 31f28bc commit 75b26e6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/dnsmasq/option.c
Original file line number Diff line number Diff line change
Expand Up @@ -1339,7 +1339,7 @@ static void dhcp_netid_free(struct dhcp_netid *nid)

/* Parse one or more tag:s before parameters.
* Moves arg to the end of tags. */
static struct dhcp_netid * dhcp_tags(char **arg)
static struct dhcp_netid *dhcp_tags(char **arg)
{
struct dhcp_netid *id = NULL;

Expand All @@ -1363,7 +1363,13 @@ static void dhcp_netid_list_free(struct dhcp_netid_list *netid)
{
struct dhcp_netid_list *tmplist = netid;
netid = netid->next;
dhcp_netid_free(tmplist->list);
/* Note: don't use dhcp_netid_free() here, since that
frees a list linked on netid->next. Where a netid_list
is used that's because the the ->next pointers in the
netids are being used to temporarily construct
a list of valid tags. */
free(tmplist->list->net);
free(tmplist->list);
free(tmplist);
}
}
Expand Down

0 comments on commit 75b26e6

Please sign in to comment.