mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 08:25:20 +09:00
sd-dhcp: explicitly set buffer size of each type
This commit is contained in:
@@ -32,7 +32,7 @@ typedef struct sd_dhcp_client_id {
|
||||
} _packed_ eth;
|
||||
struct {
|
||||
/* 2 - 254: ARP/Link-Layer (RFC 2132) */
|
||||
uint8_t haddr[0];
|
||||
uint8_t haddr[HW_ADDR_MAX_SIZE];
|
||||
} _packed_ ll;
|
||||
struct {
|
||||
/* 255: Node-specific (RFC 4361) */
|
||||
@@ -46,6 +46,8 @@ typedef struct sd_dhcp_client_id {
|
||||
};
|
||||
} sd_dhcp_client_id;
|
||||
|
||||
assert_cc(sizeof_field(sd_dhcp_client_id, id) <= MAX_CLIENT_ID_LEN);
|
||||
|
||||
static inline bool client_id_size_is_valid(size_t size) {
|
||||
return size >= MIN_CLIENT_ID_LEN && size <= MAX_CLIENT_ID_LEN;
|
||||
}
|
||||
|
||||
@@ -36,17 +36,19 @@ struct duid {
|
||||
/* DUID_TYPE_LLT */
|
||||
be16_t htype;
|
||||
be32_t time;
|
||||
uint8_t haddr[];
|
||||
uint8_t haddr[HW_ADDR_MAX_SIZE];
|
||||
} _packed_ llt;
|
||||
struct {
|
||||
/* DUID_TYPE_EN */
|
||||
be32_t pen;
|
||||
uint8_t id[];
|
||||
/* The maximum length of vendor ID is not provided in RFC 8415, but we use 8 bytes.
|
||||
* See https://datatracker.ietf.org/doc/html/rfc8415#section-11.3 */
|
||||
uint8_t id[8];
|
||||
} _packed_ en;
|
||||
struct {
|
||||
/* DUID_TYPE_LL */
|
||||
be16_t htype;
|
||||
uint8_t haddr[];
|
||||
uint8_t haddr[HW_ADDR_MAX_SIZE];
|
||||
} _packed_ ll;
|
||||
struct {
|
||||
/* DUID_TYPE_UUID */
|
||||
@@ -56,6 +58,8 @@ struct duid {
|
||||
};
|
||||
} _packed_;
|
||||
|
||||
assert_cc(sizeof(struct duid) == MAX_DUID_LEN);
|
||||
|
||||
typedef struct sd_dhcp_duid {
|
||||
size_t size;
|
||||
union {
|
||||
|
||||
Reference in New Issue
Block a user