summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@diac24.net>2019-06-12 23:17:26 +0200
committerDavid Lamparter <equinox@diac24.net>2019-06-13 20:43:13 +0200
commit6dcef54cbf8e08e6b9fde2997375818f4fb9a2e8 (patch)
tree466b91b6dbf1611c6c98ef13d1dd0d63898cd5c9
parentbgpd/rfapi: fix clang-SA warning (diff)
downloadfrr-6dcef54cbf8e08e6b9fde2997375818f4fb9a2e8.tar.xz
frr-6dcef54cbf8e08e6b9fde2997375818f4fb9a2e8.zip
bgpd: fix uninitialized & wrong endian NOTIFY
notify_data_remote_as4 would contain garbage if optlen == 0, and also as4 is in host byte order while the notify needs network byte order. Signed-off-by: David Lamparter <equinox@diac24.net>
-rw-r--r--bgpd/bgp_packet.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c
index 655a4745c..295e62b7c 100644
--- a/bgpd/bgp_packet.c
+++ b/bgpd/bgp_packet.c
@@ -1045,7 +1045,7 @@ static int bgp_open_receive(struct peer *peer, bgp_size_t size)
uint16_t holdtime;
uint16_t send_holdtime;
as_t remote_as;
- as_t as4 = 0;
+ as_t as4 = 0, as4_be;
struct in_addr remote_id;
int mp_capability;
uint8_t notify_data_remote_as[2];
@@ -1088,9 +1088,11 @@ static int bgp_open_receive(struct peer *peer, bgp_size_t size)
* that we do not know which peer is connecting to us now.
*/
as4 = peek_for_as4_capability(peer, optlen);
- memcpy(notify_data_remote_as4, &as4, 4);
}
+ as4_be = htonl(as4);
+ memcpy(notify_data_remote_as4, &as4_be, 4);
+
/* Just in case we have a silly peer who sends AS4 capability set to 0
*/
if (CHECK_FLAG(peer->cap, PEER_CAP_AS4_RCV) && !as4) {