mirror of
https://github.com/pi-hole/dnsmasq.git
synced 2025-12-19 10:18:25 +00:00
Fix use-after-free in cache_remove_uid().
Thanks to Kevin Darbyshire-Bryant for the bug report.
This commit is contained in:
@@ -425,18 +425,21 @@ unsigned int cache_remove_uid(const unsigned int uid)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
unsigned int removed = 0;
|
unsigned int removed = 0;
|
||||||
struct crec *crecp, **up;
|
struct crec *crecp, *tmp, **up;
|
||||||
|
|
||||||
for (i = 0; i < hash_size; i++)
|
for (i = 0; i < hash_size; i++)
|
||||||
for (crecp = hash_table[i], up = &hash_table[i]; crecp; crecp = crecp->hash_next)
|
for (crecp = hash_table[i], up = &hash_table[i]; crecp; crecp = tmp)
|
||||||
|
{
|
||||||
|
tmp = crecp->hash_next;
|
||||||
if ((crecp->flags & (F_HOSTS | F_DHCP | F_CONFIG)) && crecp->uid == uid)
|
if ((crecp->flags & (F_HOSTS | F_DHCP | F_CONFIG)) && crecp->uid == uid)
|
||||||
{
|
{
|
||||||
*up = crecp->hash_next;
|
*up = tmp;
|
||||||
free(crecp);
|
free(crecp);
|
||||||
removed++;
|
removed++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
up = &crecp->hash_next;
|
up = &crecp->hash_next;
|
||||||
|
}
|
||||||
|
|
||||||
return removed;
|
return removed;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user