From 454d85cf6235f83f35c9023ffaaae3676d28c0fb Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Mon, 6 Jan 2020 20:09:23 -0500 Subject: [PATCH] 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 --- bgpd/bgp_route.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 21d737fb32..b216f85c40 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -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; } -- 2.39.5