diff options
| author | Philippe Guibert <philippe.guibert@6wind.com> | 2024-04-29 15:43:29 +0200 |
|---|---|---|
| committer | Philippe Guibert <philippe.guibert@6wind.com> | 2024-04-29 15:44:24 +0200 |
| commit | f101108e3ecc27bd266128d82d8c506834a3a456 (patch) | |
| tree | 122e9b24cbe88a956727b91241f7755c5bc72a5d /bgpd/bgp_fsm.c | |
| parent | 5f059e0c7d2b6b8bce0a618726ba5d731f2d2ad4 (diff) | |
bgpd: fix covery ID 1585206
The return value of bgp_getsockname() should always be
checked.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Diffstat (limited to 'bgpd/bgp_fsm.c')
| -rw-r--r-- | bgpd/bgp_fsm.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c index 7866adbdcd..6ec26d35f5 100644 --- a/bgpd/bgp_fsm.c +++ b/bgpd/bgp_fsm.c @@ -1801,14 +1801,18 @@ bgp_connect_fail(struct peer_connection *connection) */ static void bgp_connect_in_progress_update_connection(struct peer *peer) { - bgp_getsockname(peer); - if (!peer->su_remote && !BGP_CONNECTION_SU_UNSPEC(peer->connection)) { - /* if connect initiated, then dest port and dest addresses are well known */ - peer->su_remote = sockunion_dup(&peer->connection->su); - if (sockunion_family(peer->su_remote) == AF_INET) - peer->su_remote->sin.sin_port = htons(peer->port); - else if (sockunion_family(peer->su_remote) == AF_INET6) - peer->su_remote->sin6.sin6_port = htons(peer->port); + if (bgp_getsockname(peer) < 0) { + if (!peer->su_remote && + !BGP_CONNECTION_SU_UNSPEC(peer->connection)) { + /* if connect initiated, then dest port and dest addresses are well known */ + peer->su_remote = sockunion_dup(&peer->connection->su); + if (sockunion_family(peer->su_remote) == AF_INET) + peer->su_remote->sin.sin_port = + htons(peer->port); + else if (sockunion_family(peer->su_remote) == AF_INET6) + peer->su_remote->sin6.sin6_port = + htons(peer->port); + } } } |
