From 8629ea6839dcaf79b85e606248bd7dbd85b3b509 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 2633fcb800..d7f7fb0112 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -4468,7 +4468,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