mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-01 17:35:17 +00:00
virNetworkDefUpdateIPDHCPHost: Don't crash when updating network
https://bugzilla.redhat.com/show_bug.cgi?id=1182486 When updating a network and adding new ip-dhcp-host entry, the deamon may crash. The problem is, we iterate over existing <host/> entries trying to compare MAC addresses to see if there's already an existing rule. However, not all entries are required to have MAC address. For instance, the following is perfectly valid entry: <host id='00:04:58:fd:e4:15:1b:09:4c:0e:09:af:e4:d3:8c:b8:ca:1e' name='redhatipv6.redhat.com' ip='2001:db8:ca2:2::119'/> When the checking loop iterates over this, the entry's MAC address is accessed directly. Well, the fix is obvious - check if the address is defined before trying to compare it. Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
dd69a14f90
commit
7d3ae359db
@ -3563,7 +3563,7 @@ virNetworkDefUpdateIPDHCPHost(virNetworkDefPtr def,
|
||||
/* search for the entry with this (ip|mac|name),
|
||||
* and update the IP+(mac|name) */
|
||||
for (i = 0; i < ipdef->nhosts; i++) {
|
||||
if ((host.mac &&
|
||||
if ((host.mac && ipdef->hosts[i].mac &&
|
||||
!virMacAddrCompare(host.mac, ipdef->hosts[i].mac)) ||
|
||||
(VIR_SOCKET_ADDR_VALID(&host.ip) &&
|
||||
virSocketAddrEqual(&host.ip, &ipdef->hosts[i].ip)) ||
|
||||
@ -3601,7 +3601,7 @@ virNetworkDefUpdateIPDHCPHost(virNetworkDefPtr def,
|
||||
|
||||
/* log error if an entry with same name/address/ip already exists */
|
||||
for (i = 0; i < ipdef->nhosts; i++) {
|
||||
if ((host.mac &&
|
||||
if ((host.mac && ipdef->hosts[i].mac &&
|
||||
!virMacAddrCompare(host.mac, ipdef->hosts[i].mac)) ||
|
||||
(host.name &&
|
||||
STREQ_NULLABLE(host.name, ipdef->hosts[i].name)) ||
|
||||
@ -3630,7 +3630,7 @@ virNetworkDefUpdateIPDHCPHost(virNetworkDefPtr def,
|
||||
|
||||
/* find matching entry - all specified attributes must match */
|
||||
for (i = 0; i < ipdef->nhosts; i++) {
|
||||
if ((!host.mac ||
|
||||
if ((!host.mac || !ipdef->hosts[i].mac ||
|
||||
!virMacAddrCompare(host.mac, ipdef->hosts[i].mac)) &&
|
||||
(!host.name ||
|
||||
STREQ_NULLABLE(host.name, ipdef->hosts[i].name)) &&
|
||||
|
Loading…
x
Reference in New Issue
Block a user