Skip to content

Commit

Permalink
n-dhcp4-client: check broadcast_mac field in n_dhcp4_client_config_se…
Browse files Browse the repository at this point in the history
…t_broadcast_mac()

Since the "mac" and "broadcast_mac" fields have the same size, there
was no actual bug here. Still, it feels more correct.

nettools#36
  • Loading branch information
thom311 committed Aug 11, 2022
1 parent 7db7dc4 commit f8fc48d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/n-dhcp4-client.c
Expand Up @@ -214,8 +214,8 @@ _c_public_ void n_dhcp4_client_config_set_mac(NDhcp4ClientConfig *config, const
_c_public_ void n_dhcp4_client_config_set_broadcast_mac(NDhcp4ClientConfig *config, const uint8_t *mac, size_t n_mac) {
config->n_broadcast_mac = n_mac;

if (n_mac > sizeof(config->mac))
n_mac = sizeof(config->mac);
if (n_mac > sizeof(config->broadcast_mac))
n_mac = sizeof(config->broadcast_mac);

memcpy(config->broadcast_mac, mac, n_mac);
}
Expand Down

0 comments on commit f8fc48d

Please sign in to comment.