Merge pull request #1406 from donaldsharp/bgpd_ecommunity_crash

bgpd: Fix crash with ecommunity string
This commit is contained in:
Renato Westphal 2017-11-06 15:08:07 -02:00 committed by GitHub
commit 965a99f58a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View File

@ -702,8 +702,12 @@ char *ecommunity_ecom2str(struct ecommunity *ecom, int format, int filter)
len = sprintf( len = sprintf(
str_buf + str_pnt, str_buf + str_pnt,
"EVPN:%02x:%02x:%02x:%02x:%02x:%02x", "EVPN:%02x:%02x:%02x:%02x:%02x:%02x",
macaddr[0], macaddr[1], macaddr[2], (uint8_t)macaddr[0],
macaddr[3], macaddr[4], macaddr[5]); (uint8_t)macaddr[1],
(uint8_t)macaddr[2],
(uint8_t)macaddr[3],
(uint8_t)macaddr[4],
(uint8_t)macaddr[5]);
} else if (*pnt } else if (*pnt
== ECOMMUNITY_EVPN_SUBTYPE_MACMOBILITY) { == ECOMMUNITY_EVPN_SUBTYPE_MACMOBILITY) {
u_int32_t seqnum; u_int32_t seqnum;

View File

@ -2012,6 +2012,7 @@ static int bgp_capability_msg_parse(struct peer *peer, u_char *pnt,
/* Fetch structure to the byte stream. */ /* Fetch structure to the byte stream. */
memcpy(&mpc, pnt + 3, sizeof(struct capability_mp_data)); memcpy(&mpc, pnt + 3, sizeof(struct capability_mp_data));
pnt += hdr->length + 3;
/* We know MP Capability Code. */ /* We know MP Capability Code. */
if (hdr->code == CAPABILITY_CODE_MP) { if (hdr->code == CAPABILITY_CODE_MP) {
@ -2064,7 +2065,6 @@ static int bgp_capability_msg_parse(struct peer *peer, u_char *pnt,
"%s unrecognized capability code: %d - ignored", "%s unrecognized capability code: %d - ignored",
peer->host, hdr->code); peer->host, hdr->code);
} }
pnt += hdr->length + 3;
} }
return 0; return 0;
} }