platform: fix possible out-of-bounds access with RA route masking
If the prefix length was 128, that could cause an access beyond the end of the array. Found by Thomas Haller.
This commit is contained in:
@@ -415,9 +415,13 @@ set_address_masked (struct in6_addr *dst, struct in6_addr *src, guint8 plen)
|
|||||||
g_assert (src);
|
g_assert (src);
|
||||||
g_assert (dst);
|
g_assert (dst);
|
||||||
|
|
||||||
|
if (plen >= 128)
|
||||||
|
*dst = *src;
|
||||||
|
else {
|
||||||
memset (dst, 0, sizeof (*dst));
|
memset (dst, 0, sizeof (*dst));
|
||||||
memcpy (dst, src, nbytes);
|
memcpy (dst, src, nbytes);
|
||||||
dst->s6_addr[nbytes] = (src->s6_addr[nbytes] & (0xFF << (8 - nbits)));
|
dst->s6_addr[nbytes] = (src->s6_addr[nbytes] & (0xFF << (8 - nbits)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
Reference in New Issue
Block a user