mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-05 00:38:07 +02:00
libnm: fix bounds check in _get_mac_blacklist_item()
The bounds checks are incorrect, as we cannot access the array at `idx == len`. https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1767 Fixes:dfcb221337('libnm-core: make _get_mac_address_blacklist() methods return arrays') (cherry picked from commit94fd9aed1e)
This commit is contained in:
parent
7713f4e90a
commit
1b98e30927
2 changed files with 12 additions and 2 deletions
|
|
@ -325,7 +325,12 @@ nm_setting_wired_get_mac_blacklist_item(NMSettingWired *setting, guint32 idx)
|
|||
g_return_val_if_fail(NM_IS_SETTING_WIRED(setting), NULL);
|
||||
|
||||
priv = NM_SETTING_WIRED_GET_PRIVATE(setting);
|
||||
g_return_val_if_fail(idx <= priv->mac_address_blacklist->len, NULL);
|
||||
|
||||
if (idx == priv->mac_address_blacklist->len) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
g_return_val_if_fail(idx < priv->mac_address_blacklist->len, NULL);
|
||||
|
||||
return nm_g_array_index(priv->mac_address_blacklist, const char *, idx);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -510,7 +510,12 @@ nm_setting_wireless_get_mac_blacklist_item(NMSettingWireless *setting, guint32 i
|
|||
g_return_val_if_fail(NM_IS_SETTING_WIRELESS(setting), NULL);
|
||||
|
||||
priv = NM_SETTING_WIRELESS_GET_PRIVATE(setting);
|
||||
g_return_val_if_fail(idx <= priv->mac_address_blacklist->len, NULL);
|
||||
|
||||
if (idx == priv->mac_address_blacklist->len) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
g_return_val_if_fail(idx < priv->mac_address_blacklist->len, NULL);
|
||||
|
||||
return nm_g_array_index(priv->mac_address_blacklist, const char *, idx);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue