diff options
| author | Donatas Abraitis <donatas@opensourcerouting.org> | 2024-01-16 14:36:20 +0200 | 
|---|---|---|
| committer | Donatas Abraitis <donatas@opensourcerouting.org> | 2024-01-16 14:36:20 +0200 | 
| commit | 9b178d246ebeade3beced818eb03d5dac2c1fc2b (patch) | |
| tree | 0b5be6a3713bbdea37627bc7e2c10537c63d5073 /bgpd/bgp_open.c | |
| parent | b571176aea651de626e830b9e79e848851eb982d (diff) | |
bgpd: Set ADD-PATH capability received flag only if parsed correctly
If we receive a malformed packet, we might end-up with a bad state.
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
Diffstat (limited to 'bgpd/bgp_open.c')
| -rw-r--r-- | bgpd/bgp_open.c | 4 | 
1 files changed, 2 insertions, 2 deletions
diff --git a/bgpd/bgp_open.c b/bgpd/bgp_open.c index b85e717457..8b4f97d625 100644 --- a/bgpd/bgp_open.c +++ b/bgpd/bgp_open.c @@ -662,8 +662,6 @@ static int bgp_capability_addpath(struct peer *peer,  	struct stream *s = BGP_INPUT(peer);  	size_t end = stream_get_getp(s) + hdr->length; -	SET_FLAG(peer->cap, PEER_CAP_ADDPATH_RCV); -  	/* Verify length is a multiple of 4 */  	if (hdr->length % CAPABILITY_CODE_ADDPATH_LEN) {  		flog_warn( @@ -673,6 +671,8 @@ static int bgp_capability_addpath(struct peer *peer,  		return -1;  	} +	SET_FLAG(peer->cap, PEER_CAP_ADDPATH_RCV); +  	while (stream_get_getp(s) + CAPABILITY_CODE_ADDPATH_LEN <= end) {  		afi_t afi;  		safi_t safi;  | 
