]> git.proxmox.com Git - mirror_frr.git/commitdiff
bgpd: fix unaligned access to addpath id
authorQuentin Young <qlyoung@cumulusnetworks.com>
Tue, 7 Jan 2020 01:09:23 +0000 (20:09 -0500)
committerQuentin Young <qlyoung@cumulusnetworks.com>
Tue, 7 Jan 2020 01:09:23 +0000 (20:09 -0500)
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>
bgpd/bgp_route.c

index 21d737fb32847ac291f003b783d252954f90301b..b216f85c40c48e548210032030222c3f3b7e4697 100644 (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;
                }