ndisc-option: use memcpy_safe() at one more place
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 18 Nov 2024 04:28:27 +0000 (13:28 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 18 Nov 2024 19:04:14 +0000 (04:04 +0900)
As 'len' may be 8.

Follow-up for a163404cc88914142ef8bbfaab0eb39d1a990c02.

src/libsystemd-network/ndisc-option.c

index d784ffb3ff06d7e4734c45d063d9081bcb2fc88d..3aab51f51bc875fee14a6e9796c61076fd5926db 100644 (file)
@@ -750,7 +750,7 @@ static int ndisc_option_parse_route(Set **options, size_t offset, size_t len, co
         usec_t lifetime = unaligned_be32_sec_to_usec(opt + 4, /* max_as_infinity = */ true);
 
         struct in6_addr prefix;
-        memcpy(&prefix, opt + 8, len - 8);
+        memcpy_safe(&prefix, opt + 8, len - 8);
         in6_addr_mask(&prefix, prefixlen);
 
         return ndisc_option_add_route(options, offset, preference, prefixlen, &prefix, lifetime);