diff options
author | Chris Hall <GMCH@hestia.halldom.com> | 2010-02-04 14:28:35 +0000 |
---|---|---|
committer | Chris Hall <GMCH@hestia.halldom.com> | 2010-02-04 14:28:35 +0000 |
commit | d8921b6522d8b55f3de87f90c4cdc0755acf8c7f (patch) | |
tree | ff4a9c0f119e08b4f58bce905e72ad7a05c6867d /bgpd/bgp_msg_read.c | |
parent | 8f50e8a0730a3feb670da99e979ed4c415ad5543 (diff) | |
download | quagga-d8921b6522d8b55f3de87f90c4cdc0755acf8c7f.tar.bz2 quagga-d8921b6522d8b55f3de87f90c4cdc0755acf8c7f.tar.xz |
Review and tidy new code and comments.
Follows David Lamparter's code for update-source handling.
modified: bgpd/bgp_connection.c
modified: bgpd/bgp_connection.h
modified: bgpd/bgp_fsm.c
modified: bgpd/bgp_fsm.h
modified: bgpd/bgp_msg_read.c
modified: bgpd/bgp_msg_read.h
modified: bgpd/bgp_notification.c
modified: bgpd/bgp_notification.h
modified: bgpd/bgp_peer.c
modified: bgpd/bgp_peer.h
modified: bgpd/bgp_session.c
modified: bgpd/bgp_session.h
modified: lib/prefix.c
modified: lib/prefix.h
Diffstat (limited to 'bgpd/bgp_msg_read.c')
-rw-r--r-- | bgpd/bgp_msg_read.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/bgpd/bgp_msg_read.c b/bgpd/bgp_msg_read.c index fbc163d7..9b02fddc 100644 --- a/bgpd/bgp_msg_read.c +++ b/bgpd/bgp_msg_read.c @@ -53,14 +53,22 @@ static void bgp_msg_capability_receive(bgp_connection connection, bgp_size_t body_size) ; /*------------------------------------------------------------------------------ - * Get BGP message length, given a pointer to the start of a message + * Get BGP message length, given a pointer to the start of a message. + * + * Make sure things are kosher. */ extern bgp_size_t -bgp_msg_get_mlen(uint8_t* p) +bgp_msg_get_mlen(uint8_t* p, uint8_t* limit) { - return (*(p + BGP_MH_MARKER_L)) + (*(p + BGP_MH_MARKER_L + 1) << 8) ; -} ; + uint16_t mlen ; + passert((p + BGP_MH_HEAD_L) <= limit) ; + + mlen = (*(p + BGP_MH_MARKER_L)) + (*(p + BGP_MH_MARKER_L + 1) << 8) ; + passert((p + mlen) <= limit) ; + + return mlen ; +} ; /*============================================================================== * Header validation and sexing of messages |