summaryrefslogtreecommitdiff
path: root/accel-pppd/ctrl/ipoe
diff options
context:
space:
mode:
authorDenys Fedoryshchenko <denys.f@collabora.com>2026-09-01 08:52:55 +0300
committerGitHub <noreply@github.com>2026-09-01 08:52:55 +0300
commit57ae56148c5519b9207ede623098d3cfad5211b8 (patch)
tree78dbd6a720ad8bb727ed50c53af1c2e96d779bd3 /accel-pppd/ctrl/ipoe
parent40575b78b7bb043c7a0ff4dd29a048be056dee9f (diff)
parent3b228d5c750ba76694bacf75e7be40a024927a31 (diff)
downloadaccel-ppp-57ae56148c5519b9207ede623098d3cfad5211b8.tar.gz
accel-ppp-57ae56148c5519b9207ede623098d3cfad5211b8.zip
Merge pull request #351 from nuclearcat/various-fixes-on-compiler-warnings
Various fixes on compiler warnings
Diffstat (limited to 'accel-pppd/ctrl/ipoe')
-rw-r--r--accel-pppd/ctrl/ipoe/dhcpv4_options.c33
-rw-r--r--accel-pppd/ctrl/ipoe/ipoe.c8
2 files changed, 24 insertions, 17 deletions
diff --git a/accel-pppd/ctrl/ipoe/dhcpv4_options.c b/accel-pppd/ctrl/ipoe/dhcpv4_options.c
index bffcfa5c..042a7406 100644
--- a/accel-pppd/ctrl/ipoe/dhcpv4_options.c
+++ b/accel-pppd/ctrl/ipoe/dhcpv4_options.c
@@ -265,7 +265,9 @@ 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;
+ unsigned int prefix_len, i;
+ int mask;
+ uint32_t mask1;
uint32_t ip;
uint32_t gw;
@@ -274,20 +276,23 @@ static void print_classless_route(const struct dhcpv4_option *opt, int elem_size
print(",");
mask = *ptr++;
- ip = ntohl(*(uint32_t *)ptr);
- for (i = 0; i < mask; i++)
- mask1 |= (1 << (32 - i));
+ if (mask > 32)
+ return;
+
+ prefix_len = (mask + 7) / 8;
+ if ((size_t)(endptr - ptr) < prefix_len + sizeof(gw))
+ return;
+
+ ip = 0;
+ for (i = 0; i < prefix_len; i++)
+ ip |= (uint32_t)ptr[i] << (24 - i * 8);
+ mask1 = mask ? UINT32_MAX << (32 - mask) : 0;
ip &= mask1;
- if (mask <= 8)
- ptr++;
- else if (mask <= 16)
- ptr += 2;
- else if (mask <= 24)
- ptr += 3;
- else
- ptr += 4;
- gw = ntohl(*(uint32_t *)ptr);
- ptr += 4;
+ ptr += prefix_len;
+
+ memcpy(&gw, ptr, sizeof(gw));
+ gw = ntohl(gw);
+ ptr += sizeof(gw);
print("%i.%i.%i.%i/%i via %i.%i.%i.%i",
(ip >> 24) & 0xff,
diff --git a/accel-pppd/ctrl/ipoe/ipoe.c b/accel-pppd/ctrl/ipoe/ipoe.c
index 18e9228d..1e3f7054 100644
--- a/accel-pppd/ctrl/ipoe/ipoe.c
+++ b/accel-pppd/ctrl/ipoe/ipoe.c
@@ -3814,6 +3814,7 @@ static void parse_local_net(const char *opt)
char str[17];
in_addr_t addr;
int mask;
+ unsigned long val;
char *endptr;
struct local_net *n;
@@ -3824,9 +3825,10 @@ static void parse_local_net(const char *opt)
addr = inet_addr(str);
if (addr == INADDR_NONE)
goto out_err;
- mask = strtoul(ptr + 1, &endptr, 10);
- if (mask > 32)
+ val = strtoul(ptr + 1, &endptr, 10);
+ if (*endptr || val > 32)
goto out_err;
+ mask = val;
} else {
addr = inet_addr(opt);
if (addr == INADDR_NONE)
@@ -3834,7 +3836,7 @@ static void parse_local_net(const char *opt)
mask = 24;
}
- mask = htonl(mask ? ~0 << (32 - mask) : 0);
+ mask = htonl(mask ? UINT32_MAX << (32 - mask) : 0);
addr = addr & mask;
list_for_each_entry(n, &local_nets, entry) {