]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
dhcp: DUID-EN identifier has variable length
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 22 Aug 2023 05:44:13 +0000 (14:44 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 24 Aug 2023 10:52:35 +0000 (19:52 +0900)
Also make `array[0]` -> `array[]`.

See RFC 8415, section 11.3.

src/libsystemd-network/dhcp-identifier.c
src/libsystemd-network/dhcp-identifier.h

index b0572585e6003a91845f70a1d7ed564b6747c427..c905704ab5e85a4446360affab180da004d17390 100644 (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);
index 28acb2ca5650074580e6824077965c39c0e03a99..efb266ef804553914ff98150fe169e1136c6f34e 100644 (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 */