mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-24 13:35:17 +00:00
Set the number of elements 0 in virNetwork*Clear
Decrementing it when it was already 0 causes an invalid free in virNetworkDefUpdateDNSHost if virNetworkDNSHostDefParseXML fails and virNetworkDNSHostDefClear gets called twice. virNetworkForwardDefClear left the number untouched even if it freed all the elements. (cherry picked from commit c4e23388e6c7f769e45d1c162f880cd81e4d4d3b)
This commit is contained in:
parent
80fffee94b
commit
f32ea9937f
@ -134,8 +134,8 @@ virNetworkIpDefClear(virNetworkIpDefPtr def)
|
|||||||
VIR_FREE(def->family);
|
VIR_FREE(def->family);
|
||||||
VIR_FREE(def->ranges);
|
VIR_FREE(def->ranges);
|
||||||
|
|
||||||
while (def->nhosts--)
|
while (def->nhosts)
|
||||||
virNetworkDHCPHostDefClear(&def->hosts[def->nhosts]);
|
virNetworkDHCPHostDefClear(&def->hosts[--def->nhosts]);
|
||||||
|
|
||||||
VIR_FREE(def->hosts);
|
VIR_FREE(def->hosts);
|
||||||
VIR_FREE(def->tftproot);
|
VIR_FREE(def->tftproot);
|
||||||
@ -152,8 +152,8 @@ virNetworkDNSTxtDefClear(virNetworkDNSTxtDefPtr def)
|
|||||||
static void
|
static void
|
||||||
virNetworkDNSHostDefClear(virNetworkDNSHostDefPtr def)
|
virNetworkDNSHostDefClear(virNetworkDNSHostDefPtr def)
|
||||||
{
|
{
|
||||||
while (def->nnames--)
|
while (def->nnames)
|
||||||
VIR_FREE(def->names[def->nnames]);
|
VIR_FREE(def->names[--def->nnames]);
|
||||||
VIR_FREE(def->names);
|
VIR_FREE(def->names);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,18 +170,18 @@ static void
|
|||||||
virNetworkDNSDefClear(virNetworkDNSDefPtr def)
|
virNetworkDNSDefClear(virNetworkDNSDefPtr def)
|
||||||
{
|
{
|
||||||
if (def->txts) {
|
if (def->txts) {
|
||||||
while (def->ntxts--)
|
while (def->ntxts)
|
||||||
virNetworkDNSTxtDefClear(&def->txts[def->ntxts]);
|
virNetworkDNSTxtDefClear(&def->txts[--def->ntxts]);
|
||||||
VIR_FREE(def->txts);
|
VIR_FREE(def->txts);
|
||||||
}
|
}
|
||||||
if (def->hosts) {
|
if (def->hosts) {
|
||||||
while (def->nhosts--)
|
while (def->nhosts)
|
||||||
virNetworkDNSHostDefClear(&def->hosts[def->nhosts]);
|
virNetworkDNSHostDefClear(&def->hosts[--def->nhosts]);
|
||||||
VIR_FREE(def->hosts);
|
VIR_FREE(def->hosts);
|
||||||
}
|
}
|
||||||
if (def->srvs) {
|
if (def->srvs) {
|
||||||
while (def->nsrvs--)
|
while (def->nsrvs)
|
||||||
virNetworkDNSSrvDefClear(&def->srvs[def->nsrvs]);
|
virNetworkDNSSrvDefClear(&def->srvs[--def->nsrvs]);
|
||||||
VIR_FREE(def->srvs);
|
VIR_FREE(def->srvs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -200,6 +200,7 @@ virNetworkForwardDefClear(virNetworkForwardDefPtr def)
|
|||||||
virNetworkForwardIfDefClear(&def->ifs[ii]);
|
virNetworkForwardIfDefClear(&def->ifs[ii]);
|
||||||
}
|
}
|
||||||
VIR_FREE(def->ifs);
|
VIR_FREE(def->ifs);
|
||||||
|
def->nifs = def->npfs = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
x
Reference in New Issue
Block a user