mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-07-09 11:05:04 +00:00
zebra: Remove possible NULL dereference in if_delete_connected
It is technically possible to attempt to use a NULL pointer. Remove this from happening. Additionally cleanup code indentation a small bit. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
parent
9b7e34ec42
commit
070b4959fa
@ -561,33 +561,35 @@ static void if_delete_connected(struct interface *ifp)
|
|||||||
struct prefix cp;
|
struct prefix cp;
|
||||||
struct route_node *rn;
|
struct route_node *rn;
|
||||||
struct zebra_if *zebra_if;
|
struct zebra_if *zebra_if;
|
||||||
|
struct listnode *node;
|
||||||
|
struct listnode *last = NULL;
|
||||||
|
|
||||||
zebra_if = ifp->info;
|
zebra_if = ifp->info;
|
||||||
|
|
||||||
if (ifp->connected) {
|
if (!ifp->connected)
|
||||||
struct listnode *node;
|
return;
|
||||||
struct listnode *last = NULL;
|
|
||||||
|
|
||||||
while ((node = (last ? last->next
|
while ((node = (last ? last->next
|
||||||
: listhead(ifp->connected)))) {
|
: listhead(ifp->connected)))) {
|
||||||
ifc = listgetdata(node);
|
ifc = listgetdata(node);
|
||||||
|
|
||||||
cp = *CONNECTED_PREFIX(ifc);
|
cp = *CONNECTED_PREFIX(ifc);
|
||||||
apply_mask(&cp);
|
apply_mask(&cp);
|
||||||
|
|
||||||
if (cp.family == AF_INET
|
if (cp.family == AF_INET
|
||||||
&& (rn = route_node_lookup(zebra_if->ipv4_subnets,
|
&& (rn = route_node_lookup(zebra_if->ipv4_subnets,
|
||||||
&cp))) {
|
&cp))) {
|
||||||
struct listnode *anode;
|
struct listnode *anode;
|
||||||
struct listnode *next;
|
struct listnode *next;
|
||||||
struct listnode *first;
|
struct listnode *first;
|
||||||
struct list *addr_list;
|
struct list *addr_list;
|
||||||
|
|
||||||
route_unlock_node(rn);
|
route_unlock_node(rn);
|
||||||
addr_list = (struct list *)rn->info;
|
addr_list = (struct list *)rn->info;
|
||||||
|
|
||||||
/* Remove addresses, secondaries first. */
|
/* Remove addresses, secondaries first. */
|
||||||
first = listhead(addr_list);
|
first = listhead(addr_list);
|
||||||
|
if (first)
|
||||||
for (anode = first->next; anode || first;
|
for (anode = first->next; anode || first;
|
||||||
anode = next) {
|
anode = next) {
|
||||||
if (!anode) {
|
if (!anode) {
|
||||||
@ -626,27 +628,26 @@ static void if_delete_connected(struct interface *ifp)
|
|||||||
last = node;
|
last = node;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free chain list and respective route node. */
|
/* Free chain list and respective route node. */
|
||||||
list_delete_and_null(&addr_list);
|
list_delete_and_null(&addr_list);
|
||||||
rn->info = NULL;
|
rn->info = NULL;
|
||||||
route_unlock_node(rn);
|
route_unlock_node(rn);
|
||||||
} else if (cp.family == AF_INET6) {
|
} else if (cp.family == AF_INET6) {
|
||||||
connected_down(ifp, ifc);
|
connected_down(ifp, ifc);
|
||||||
|
|
||||||
zebra_interface_address_delete_update(ifp, ifc);
|
zebra_interface_address_delete_update(ifp, ifc);
|
||||||
|
|
||||||
UNSET_FLAG(ifc->conf, ZEBRA_IFC_REAL);
|
UNSET_FLAG(ifc->conf, ZEBRA_IFC_REAL);
|
||||||
UNSET_FLAG(ifc->conf, ZEBRA_IFC_QUEUED);
|
UNSET_FLAG(ifc->conf, ZEBRA_IFC_QUEUED);
|
||||||
|
|
||||||
if (CHECK_FLAG(ifc->conf, ZEBRA_IFC_CONFIGURED))
|
if (CHECK_FLAG(ifc->conf, ZEBRA_IFC_CONFIGURED))
|
||||||
last = node;
|
|
||||||
else {
|
|
||||||
listnode_delete(ifp->connected, ifc);
|
|
||||||
connected_free(ifc);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
last = node;
|
last = node;
|
||||||
|
else {
|
||||||
|
listnode_delete(ifp->connected, ifc);
|
||||||
|
connected_free(ifc);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
last = node;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user