]> git.puffer.fish Git - matthieu/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>
Wed, 15 Jan 2020 17:52:43 +0000 (12:52 -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 2633fcb8004645316e880b85bcbb586536252759..d7f7fb0112d5d8db44aaee222b38d61f7debbe92 100644 (file)
@@ -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;
                }