bgpd: fix unaligned access to addpath id

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>
This commit is contained in:
Quentin Young 2020-01-06 20:09:23 -05:00
parent 5c3be0814f
commit 454d85cf62

View File

@ -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;
}