Commit f1ee20c9 for quagga.net
commit f1ee20c940a712c685f5435d2d5af212a8f76702
Author: Paul Jakma <paul@jakma.org>
Date: Thu Jan 4 00:22:53 2018 +0000
bgpd: remove stream_pnt use for notify data
* bgp_packet.c: (bgp_open_receive) Remove the stream_pnt introduced
in c69698704806a9ac50. stream_pnt / BGP_INPUT_PNT / etc. should be avoided
as much possible, and I/O put through the lib/stream checked buffer as much
as possible.
Not really any functional effect here given the fixed size, other than to
remove something that shouldn't be copied.
diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c
index f9338d8d..5a8b18a3 100644
--- a/bgpd/bgp_packet.c
+++ b/bgpd/bgp_packet.c
@@ -1314,7 +1314,6 @@ bgp_open_receive (struct peer *peer, bgp_size_t size)
int mp_capability;
u_int8_t notify_data_remote_as[2];
u_int8_t notify_data_remote_id[4];
- u_int16_t *holdtime_ptr;
realpeer = NULL;
@@ -1322,7 +1321,6 @@ bgp_open_receive (struct peer *peer, bgp_size_t size)
version = stream_getc (peer->ibuf);
memcpy (notify_data_remote_as, stream_pnt (peer->ibuf), 2);
remote_as = stream_getw (peer->ibuf);
- holdtime_ptr = (u_int16_t *)stream_pnt (peer->ibuf);
holdtime = stream_getw (peer->ibuf);
memcpy (notify_data_remote_id, stream_pnt (peer->ibuf), 4);
remote_id.s_addr = stream_get_ipv4 (peer->ibuf);
@@ -1628,10 +1626,11 @@ bgp_open_receive (struct peer *peer, bgp_size_t size)
if (holdtime < 3 && holdtime != 0)
{
+ uint16_t netholdtime = htons (holdtime);
bgp_notify_send_with_data (peer,
BGP_NOTIFY_OPEN_ERR,
BGP_NOTIFY_OPEN_UNACEP_HOLDTIME,
- (u_int8_t *)holdtime_ptr, 2);
+ (u_int8_t *) &netholdtime, 2);
return -1;
}