merge: branch 'jv/fix-wireless-bounds-check'
libnm: fix bounds check in _get_mac_blacklist_item https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1767
This commit is contained in:
@@ -312,6 +312,8 @@ nm_setting_wired_get_num_mac_blacklist_items(NMSettingWired *setting)
|
||||
* @setting: the #NMSettingWired
|
||||
* @idx: the zero-based index of the MAC address entry
|
||||
*
|
||||
* Since 1.46, access at index "len" is allowed and returns NULL.
|
||||
*
|
||||
* Returns: the blacklisted MAC address string (hex-digits-and-colons notation)
|
||||
* at index @idx
|
||||
**/
|
||||
@@ -323,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);
|
||||
}
|
||||
|
@@ -497,6 +497,8 @@ nm_setting_wireless_get_num_mac_blacklist_items(NMSettingWireless *setting)
|
||||
* @setting: the #NMSettingWireless
|
||||
* @idx: the zero-based index of the MAC address entry
|
||||
*
|
||||
* Since 1.46, access at index "len" is allowed and returns NULL.
|
||||
*
|
||||
* Returns: the blacklisted MAC address string (hex-digits-and-colons notation)
|
||||
* at index @idx
|
||||
**/
|
||||
@@ -508,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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user