diff options
author | David Lamparter <equinox@opensourcerouting.org> | 2017-09-07 15:58:18 +0200 |
---|---|---|
committer | David Lamparter <equinox@opensourcerouting.org> | 2017-09-09 19:50:58 +0200 |
commit | 937652c6e43fc74ba969bbace475bdf929cdc5d0 (patch) | |
tree | f2cdea6d59fa9e2f20eafc512fe21203f6acdd6b /bgpd/bgp_ecommunity.c | |
parent | Merge pull request #1118 from opensourcerouting/attr-kill-master (diff) | |
download | frr-937652c6e43fc74ba969bbace475bdf929cdc5d0.tar.xz frr-937652c6e43fc74ba969bbace475bdf929cdc5d0.zip |
*: fix be32 reading / 24-bit left shift
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'bgpd/bgp_ecommunity.c')
-rw-r--r-- | bgpd/bgp_ecommunity.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/bgpd/bgp_ecommunity.c b/bgpd/bgp_ecommunity.c index ec52422d4..897b1c750 100644 --- a/bgpd/bgp_ecommunity.c +++ b/bgpd/bgp_ecommunity.c @@ -27,6 +27,7 @@ #include "queue.h" #include "filter.h" #include "jhash.h" +#include "stream.h" #include "bgpd/bgpd.h" #include "bgpd/bgp_ecommunity.h" @@ -583,10 +584,7 @@ static int ecommunity_rt_soo_str(char *buf, u_int8_t *pnt, int type, /* Put string into buffer. */ if (type == ECOMMUNITY_ENCODE_AS4) { - eas.as = (*pnt++ << 24); - eas.as |= (*pnt++ << 16); - eas.as |= (*pnt++ << 8); - eas.as |= (*pnt++); + pnt = ptr_get_be32(pnt, &eas.as); eas.val = (*pnt++ << 8); eas.val |= (*pnt++); @@ -594,11 +592,7 @@ static int ecommunity_rt_soo_str(char *buf, u_int8_t *pnt, int type, } else if (type == ECOMMUNITY_ENCODE_AS) { eas.as = (*pnt++ << 8); eas.as |= (*pnt++); - - eas.val = (*pnt++ << 24); - eas.val |= (*pnt++ << 16); - eas.val |= (*pnt++ << 8); - eas.val |= (*pnt++); + pnt = ptr_get_be32(pnt, &eas.val); len = sprintf(buf, "%s%u:%u", prefix, eas.as, eas.val); } else if (type == ECOMMUNITY_ENCODE_IP) { @@ -610,6 +604,7 @@ static int ecommunity_rt_soo_str(char *buf, u_int8_t *pnt, int type, len = sprintf(buf, "%s%s:%u", prefix, inet_ntoa(eip.ip), eip.val); } + (void)pnt; /* consume value */ return len; } |