From d6890c49b2f689fd679cd845d0011eecb80c326a Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Thu, 10 Mar 2022 11:22:48 +0100 Subject: [PATCH] pimd: add safety check to OIL add/del These will corrupt memory if mroute_vif_index is -1 (e.g. interface not operating.) That shouldn't happen, but it does while doing development work, so trip an assert rather than corrupting memory. Signed-off-by: David Lamparter --- pimd/pim_oil.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pimd/pim_oil.c b/pimd/pim_oil.c index a499c884b4..d5e459b44e 100644 --- a/pimd/pim_oil.c +++ b/pimd/pim_oil.c @@ -216,6 +216,10 @@ int pim_channel_del_oif(struct channel_oil *channel_oil, struct interface *oif, pim_ifp = oif->info; + assertf(pim_ifp->mroute_vif_index >= 0, + "trying to del OIF %s with VIF (%d)", oif->name, + pim_ifp->mroute_vif_index); + /* * Don't do anything if we've been asked to remove a source * that is not actually on it. @@ -418,6 +422,10 @@ int pim_channel_add_oif(struct channel_oil *channel_oil, struct interface *oif, pim_ifp = oif->info; + assertf(pim_ifp->mroute_vif_index >= 0, + "trying to add OIF %s with VIF (%d)", oif->name, + pim_ifp->mroute_vif_index); + /* Prevent single protocol from subscribing same interface to channel (S,G) multiple times */ if (channel_oil->oif_flags[pim_ifp->mroute_vif_index] & proto_mask) { -- 2.39.5