From: anlan_cs Date: Wed, 12 Jan 2022 12:53:25 +0000 (-0500) Subject: lib: fix the right value is returned for fail cases X-Git-Tag: base_8.2~55^2 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=10f02a2ac936737cb5841cec5e8c063514fd5c70;p=mirror%2Ffrr.git 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 --- diff --git a/lib/bfd.c b/lib/bfd.c index e364297457..7b711a9fba 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; }