From 464e6541b112ba7b3c77dbe8d105fcebb58056dc Mon Sep 17 00:00:00 2001 From: Rafael Zalamena Date: Mon, 12 Apr 2021 17:59:52 -0300 Subject: [PATCH] lib: fix possible crash on BFD notification Allow sessions to remove themselves from the notifications without risking crashes. Signed-off-by: Rafael Zalamena --- lib/bfd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/bfd.c b/lib/bfd.c index bf3eaa32db..b821094cdd 100644 --- a/lib/bfd.c +++ b/lib/bfd.c @@ -1080,7 +1080,7 @@ static int zclient_bfd_session_reply(ZAPI_CALLBACK_ARGS) static int zclient_bfd_session_update(ZAPI_CALLBACK_ARGS) { - struct bfd_session_params *bsp; + struct bfd_session_params *bsp, *bspn; size_t sessions_updated = 0; struct interface *ifp; int remote_cbit = false; @@ -1137,7 +1137,7 @@ static int zclient_bfd_session_update(ZAPI_CALLBACK_ARGS) now = monotime(NULL); /* Notify all matching sessions about update. */ - TAILQ_FOREACH (bsp, &bsglobal.bsplist, entry) { + TAILQ_FOREACH_SAFE (bsp, &bsglobal.bsplist, entry, bspn) { /* Skip not installed entries. */ if (!bsp->installed) continue; -- 2.39.5