diff options
| author | Denys Fedoryshchenko <denys.f@collabora.com> | 2026-09-01 08:50:35 +0300 |
|---|---|---|
| committer | Denys Fedoryshchenko <denys.f@collabora.com> | 2026-09-01 08:55:54 +0300 |
| commit | 004ec5adc7e5702c518583caef437d304932beb5 (patch) | |
| tree | 68517316725b0fcad7fe302f6ace4ccee9ed682e /accel-pppd/extra | |
| parent | cbbae583e584f83957acd99440fc67343d46b800 (diff) | |
| download | accel-ppp-004ec5adc7e5702c518583caef437d304932beb5.tar.gz accel-ppp-004ec5adc7e5702c518583caef437d304932beb5.zip | |
ipv6: avoid integer access through address bytes
Copy interface IDs and prefix words between aligned temporaries and byte arrays instead of casting IPv6 address storage to uint64_t pointers.
Diffstat (limited to 'accel-pppd/extra')
| -rw-r--r-- | accel-pppd/extra/ipv6pool.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/accel-pppd/extra/ipv6pool.c b/accel-pppd/extra/ipv6pool.c index 9a763445..05b84fe8 100644 --- a/accel-pppd/extra/ipv6pool.c +++ b/accel-pppd/extra/ipv6pool.c @@ -293,11 +293,18 @@ static void add_prefix(struct ip6_pool *pool, const char *_val) /* end = start | hostmask(mask) (matches the original generator) */ memcpy(&end, &start, sizeof(end)); - if (mask > 64) - *(uint64_t *)(end.s6_addr + 8) = htobe64(be64toh(*(uint64_t *)(end.s6_addr + 8)) | ((1llu << (128 - mask)) - 1)); + if (mask > 64) { + uint64_t value; + memcpy(&value, end.s6_addr + 8, sizeof(value)); + value = htobe64(be64toh(value) | ((1llu << (128 - mask)) - 1)); + memcpy(end.s6_addr + 8, &value, sizeof(value)); + } else { + uint64_t value; memset(end.s6_addr + 8, 0xff, 8); - *(uint64_t *)end.s6_addr = htobe64(be64toh(*(uint64_t *)end.s6_addr) | ((1llu << (64 - mask)) - 1)); + memcpy(&value, end.s6_addr, sizeof(value)); + value = htobe64(be64toh(value) | ((1llu << (64 - mask)) - 1)); + memcpy(end.s6_addr, &value, sizeof(value)); } { |
