From 937652c6e43fc74ba969bbace475bdf929cdc5d0 Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Thu, 7 Sep 2017 15:58:18 +0200 Subject: *: fix be32 reading / 24-bit left shift Signed-off-by: David Lamparter --- bgpd/bgp_clist.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) (limited to 'bgpd/bgp_clist.c') diff --git a/bgpd/bgp_clist.c b/bgpd/bgp_clist.c index b62a0a540..f3bae9535 100644 --- a/bgpd/bgp_clist.c +++ b/bgpd/bgp_clist.c @@ -25,6 +25,7 @@ #include "memory.h" #include "queue.h" #include "filter.h" +#include "stream.h" #include "bgpd/bgpd.h" #include "bgpd/bgp_community.h" @@ -465,20 +466,10 @@ static char *lcommunity_str_get(struct lcommunity *lcom, int i) str = pnt = XMALLOC(MTYPE_LCOMMUNITY_STR, 48); ptr = (u_char *)lcomval.val; - globaladmin = (*ptr++ << 24); - globaladmin |= (*ptr++ << 16); - globaladmin |= (*ptr++ << 8); - globaladmin |= (*ptr++); - - localdata1 = (*ptr++ << 24); - localdata1 |= (*ptr++ << 16); - localdata1 |= (*ptr++ << 8); - localdata1 |= (*ptr++); - - localdata2 = (*ptr++ << 24); - localdata2 |= (*ptr++ << 16); - localdata2 |= (*ptr++ << 8); - localdata2 |= (*ptr++); + ptr = ptr_get_be32(ptr, &globaladmin); + ptr = ptr_get_be32(ptr, &localdata1); + ptr = ptr_get_be32(ptr, &localdata2); + (void)ptr; /* consume value */ sprintf(pnt, "%u:%u:%u", globaladmin, localdata1, localdata2); pnt += strlen(pnt); -- cgit v1.2.3