1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-11 09:18:07 +03:00

dhcp: DUID-EN identifier has variable length

Also make `array[0]` -> `array[]`.

See RFC 8415, section 11.3.
This commit is contained in:
Yu Watanabe 2023-08-22 14:44:13 +09:00
parent 9291496011
commit 2da796cabb
2 changed files with 5 additions and 5 deletions

View File

@ -114,9 +114,9 @@ int dhcp_identifier_set_duid_en(bool test_mode, struct duid *ret_duid, size_t *r
/* a bit of snake-oil perhaps, but no need to expose the machine-id
* directly; duid->en.id might not be aligned, so we need to copy */
hash = htole64(siphash24(&machine_id, sizeof(machine_id), HASH_KEY.bytes));
memcpy(ret_duid->en.id, &hash, sizeof(ret_duid->en.id));
memcpy(ret_duid->en.id, &hash, sizeof(hash));
*ret_len = offsetof(struct duid, en.id) + sizeof(ret_duid->en.id);
*ret_len = offsetof(struct duid, en.id) + sizeof(hash);
if (test_mode)
assert_se(memcmp(ret_duid, (const uint8_t[]) { 0x00, 0x02, 0x00, 0x00, 0xab, 0x11, 0x61, 0x77, 0x40, 0xde, 0x13, 0x42, 0xc3, 0xa2 }, *ret_len) == 0);

View File

@ -35,17 +35,17 @@ struct duid {
/* DUID_TYPE_LLT */
be16_t htype;
be32_t time;
uint8_t haddr[0];
uint8_t haddr[];
} _packed_ llt;
struct {
/* DUID_TYPE_EN */
be32_t pen;
uint8_t id[8];
uint8_t id[];
} _packed_ en;
struct {
/* DUID_TYPE_LL */
be16_t htype;
uint8_t haddr[0];
uint8_t haddr[];
} _packed_ ll;
struct {
/* DUID_TYPE_UUID */