Skip to content

Commit

Permalink
bgpd: limit the length of opaque data sent to zebra
Browse files Browse the repository at this point in the history
Previously, when aspath->str was longer than sizeof(api.opaque.data), we
were overwriting the wrong memory.

Signed-off-by: Igor Ryzhov <[email protected]>
  • Loading branch information
idryzhov committed Aug 6, 2021
1 parent 3190cc2 commit 909470a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions bgpd/bgp_zebra.c
Original file line number Diff line number Diff line change
Expand Up @@ -1416,8 +1416,9 @@ void bgp_zebra_announce(struct bgp_dest *dest, const struct prefix *p,
struct aspath *aspath = info->attr->aspath;

SET_FLAG(api.message, ZAPI_MESSAGE_OPAQUE);
api.opaque.length = strlen(aspath->str) + 1;
memcpy(api.opaque.data, aspath->str, api.opaque.length);
strlcpy((char *)api.opaque.data, aspath->str,
sizeof(api.opaque.data));
api.opaque.length = strlen((char *)api.opaque.data) + 1;
}

if (allow_recursion)
Expand Down

0 comments on commit 909470a

Please sign in to comment.