diff options
Diffstat (limited to 'src/libsystemd-network/sd-dhcp-client.c')
-rw-r--r-- | src/libsystemd-network/sd-dhcp-client.c | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/src/libsystemd-network/sd-dhcp-client.c b/src/libsystemd-network/sd-dhcp-client.c index b73abcb82d..19ed80db5c 100644 --- a/src/libsystemd-network/sd-dhcp-client.c +++ b/src/libsystemd-network/sd-dhcp-client.c @@ -339,25 +339,32 @@ int sd_dhcp_client_set_mac( int sd_dhcp_client_get_client_id( sd_dhcp_client *client, - uint8_t *type, - const uint8_t **data, - size_t *data_len) { + uint8_t *ret_type, + const uint8_t **ret_data, + size_t *ret_data_len) { assert_return(client, -EINVAL); - assert_return(type, -EINVAL); - assert_return(data, -EINVAL); - assert_return(data_len, -EINVAL); - if (client->client_id_len) { - *type = client->client_id.type; - *data = client->client_id.raw.data; - *data_len = client->client_id_len - sizeof(client->client_id.type); - } else { - *type = 0; - *data = NULL; - *data_len = 0; + if (client->client_id_len > 0) { + if (client->client_id_len < offsetof(sd_dhcp_client_id, raw.data)) + return -EINVAL; + + if (ret_type) + *ret_type = client->client_id.type; + if (ret_data) + *ret_data = client->client_id.raw.data; + if (ret_data_len) + *ret_data_len = client->client_id_len - offsetof(sd_dhcp_client_id, raw.data); + return 1; } + if (ret_type) + *ret_type = 0; + if (ret_data) + *ret_data = NULL; + if (ret_data_len) + *ret_data_len = 0; + return 0; } |