From: Igor Ryzhov Date: Tue, 13 Oct 2020 21:25:35 +0000 (+0300) Subject: ospfd: fix check for network configuration X-Git-Tag: frr-7.5~4^2~4 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=1cc59f4c3fc2bb627173f98c0f18a5c4895b342d;p=mirror%2Ffrr.git ospfd: fix check for network configuration We should check for existing networks configuration before creating if_params structure, or it leads to the memory leak. Signed-off-by: Igor Ryzhov --- diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index 48f205802e..da6ba89def 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -8104,6 +8104,16 @@ DEFUN (ip_ospf_area, return CMD_WARNING_CONFIG_FAILED; } + if (ospf) { + for (rn = route_top(ospf->networks); rn; rn = route_next(rn)) { + if (rn->info != NULL) { + vty_out(vty, + "Please remove all network commands first.\n"); + return CMD_WARNING_CONFIG_FAILED; + } + } + } + params = IF_DEF_PARAMS(ifp); if (OSPF_IF_PARAM_CONFIGURED(params, if_area) && !IPV4_ADDR_SAME(¶ms->if_area, &area_id)) { @@ -8129,16 +8139,6 @@ DEFUN (ip_ospf_area, ospf_if_update_params((ifp), (addr)); } - if (ospf) { - for (rn = route_top(ospf->networks); rn; rn = route_next(rn)) { - if (rn->info != NULL) { - vty_out(vty, - "Please remove all network commands first.\n"); - return CMD_WARNING_CONFIG_FAILED; - } - } - } - /* enable ospf on this interface with area_id */ if (params) { SET_IF_PARAM(params, if_area);