summaryrefslogtreecommitdiff
path: root/accel-pppd
diff options
context:
space:
mode:
Diffstat (limited to 'accel-pppd')
-rw-r--r--accel-pppd/ctrl/ipoe/dhcpv4_options.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/accel-pppd/ctrl/ipoe/dhcpv4_options.c b/accel-pppd/ctrl/ipoe/dhcpv4_options.c
index bffcfa5c..57999995 100644
--- a/accel-pppd/ctrl/ipoe/dhcpv4_options.c
+++ b/accel-pppd/ctrl/ipoe/dhcpv4_options.c
@@ -265,7 +265,8 @@ static void print_classless_route(const struct dhcpv4_option *opt, int elem_size
{
const uint8_t *ptr = opt->data;
const uint8_t *endptr = ptr + opt->len;
- int mask, i, mask1 = 0;
+ int mask;
+ uint32_t mask1;
uint32_t ip;
uint32_t gw;
@@ -274,9 +275,11 @@ static void print_classless_route(const struct dhcpv4_option *opt, int elem_size
print(",");
mask = *ptr++;
+ if (mask > 32)
+ return;
+
ip = ntohl(*(uint32_t *)ptr);
- for (i = 0; i < mask; i++)
- mask1 |= (1 << (32 - i));
+ mask1 = mask ? UINT32_MAX << (32 - mask) : 0;
ip &= mask1;
if (mask <= 8)
ptr++;