Skip to content

Commit

Permalink
bgpd: fix unaligned access to addpath id
Browse files Browse the repository at this point in the history
uint8_t * cannot be cast to uint32_t * unless the pointed-to address is
aligned according to uint32_t's alignment rules. And it usually is not.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
  • Loading branch information
qlyoung committed Jan 7, 2020
1 parent 5c3be08 commit 454d85c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion bgpd/bgp_route.c
Expand Up @@ -4515,7 +4515,8 @@ int bgp_nlri_parse_ip(struct peer *peer, struct attr *attr,
if (pnt + BGP_ADDPATH_ID_LEN >= lim)
return BGP_NLRI_PARSE_ERROR_PACKET_OVERFLOW;

addpath_id = ntohl(*((uint32_t *)pnt));
memcpy(&addpath_id, pnt, 4);
addpath_id = ntohl(addpath_id);
pnt += BGP_ADDPATH_ID_LEN;
}

Expand Down

0 comments on commit 454d85c

Please sign in to comment.