From: Renato Westphal Date: Mon, 31 May 2021 13:27:51 +0000 (-0300) Subject: ospfd: fix crash when displaying neighbor data in JSON X-Git-Tag: base_8.1~445^2 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=b3d498f8b7d5367a49ff77d0fc8cd53ee7593bb8;p=matthieu%2Ffrr.git ospfd: fix crash when displaying neighbor data in JSON Add a null check to protect against the case where the neighbor inactive timer is disabled. That can happen when the router is acting as a helper for another router that is attempting to restart gracefully. Signed-off-by: Renato Westphal --- diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index fb2d790532..524bf8baee 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -4435,21 +4435,27 @@ static void show_ip_ospf_neighbor_sub(struct vty *vty, ospf_nbr_state_message(nbr, msgbuf, 16); - long time_store; - - time_store = - monotime_until( - &nbr->t_inactivity->u.sands, - NULL) - / 1000LL; - json_object_int_add(json_neighbor, "priority", nbr->priority); json_object_string_add(json_neighbor, "state", msgbuf); - json_object_int_add(json_neighbor, - "deadTimeMsecs", - time_store); + + if (nbr->t_inactivity) { + long time_store; + + time_store = monotime_until( + &nbr->t_inactivity + ->u.sands, + NULL) + / 1000LL; + json_object_int_add(json_neighbor, + "deadTimeMsecs", + time_store); + } else { + json_object_string_add(json_neighbor, + "deadTimeMsecs", + "inactive"); + } json_object_string_add( json_neighbor, "address", inet_ntop(AF_INET, &nbr->src,