]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib: fix the right value is returned for fail cases 10324/head
authoranlan_cs <anlan_cs@tom.com>
Wed, 12 Jan 2022 12:53:25 +0000 (07:53 -0500)
committeranlan_cs <anlan_cs@tom.com>
Wed, 12 Jan 2022 13:08:29 +0000 (08:08 -0500)
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>
lib/bfd.c

index e3642974572a66b13a7d4f89a5f6f5331a217cd7..7b711a9fba3d8786c167a33b536302a6e686b519 100644 (file)
--- 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;
 }