summaryrefslogtreecommitdiffstats
path: root/lib/bfd.c
diff options
context:
space:
mode:
authoranlan_cs <anlan_cs@tom.com>2022-01-12 13:53:25 +0100
committeranlan_cs <anlan_cs@tom.com>2022-01-12 14:08:29 +0100
commit10f02a2ac936737cb5841cec5e8c063514fd5c70 (patch)
treebf74af97457a263dcfc64ea6f4a947fcb89432b5 /lib/bfd.c
parentMerge pull request #10317 from ton31337/fix/shutdown_msg (diff)
downloadfrr-10f02a2ac936737cb5841cec5e8c063514fd5c70.tar.xz
frr-10f02a2ac936737cb5841cec5e8c063514fd5c70.zip
lib: fix the right value is returned for fail cases
Currently `bfd_get_peer_info` should return invalid sp->family and dp->family during fail cases. Before this fix, in those fail cases `bfd_get_peer_info` maybe return valid sp->family and dp->family. This fix ensures all fail cases return invalid sp->family and dp->family for outside callers. Signed-off-by: anlan_cs <anlan_cs@tom.com>
Diffstat (limited to 'lib/bfd.c')
-rw-r--r--lib/bfd.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/bfd.c b/lib/bfd.c
index e36429745..7b711a9fb 100644
--- a/lib/bfd.c
+++ b/lib/bfd.c
@@ -171,6 +171,12 @@ static struct interface *bfd_get_peer_info(struct stream *s, struct prefix *dp,
return ifp;
stream_failure:
+ /*
+ * Clean dp and sp because caller
+ * will immediately check them valid or not
+ */
+ memset(dp, 0, sizeof(*dp));
+ memset(sp, 0, sizeof(*sp));
return NULL;
}