icmp6-packet: check the alignment of struct nd_opt_hdr for safety

Addresses https://github.com/systemd/systemd/pull/31492#discussion_r1507481748.
This commit is contained in:
Yu Watanabe
2024-03-01 09:44:45 +09:00
parent 1e18e1aa11
commit bbb2a0fb41
+1
View File
@@ -22,6 +22,7 @@ int ndisc_option_parse(
if (p->raw_size - offset < sizeof(struct nd_opt_hdr))
return -EBADMSG;
assert_cc(alignof(struct nd_opt_hdr) == 1);
const struct nd_opt_hdr *hdr = (const struct nd_opt_hdr*) (p->raw_packet + offset);
if (hdr->nd_opt_len == 0)
return -EBADMSG;