1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00

net/gnrc_lorawan: fix random_uint32_range upper bound

This commit is contained in:
Jose Alamos 2021-07-21 03:12:30 +02:00
parent 0ffd04c132
commit 179a2c2780
No known key found for this signature in database
GPG Key ID: F483EB800EF89DD9

View File

@ -100,10 +100,10 @@ uint32_t gnrc_lorawan_pick_channel(gnrc_lorawan_t *mac)
{
uint8_t index = 0;
uint8_t random_number = random_uint32_range(0, bitarithm_bits_set(mac->channel_mask));
uint8_t pos = random_uint32_range(0, bitarithm_bits_set(mac->channel_mask));
unsigned state = mac->channel_mask;
for (int i = 0; i < random_number; i++) {
for (int i = 0; i < pos + 1; i++) {
state = bitarithm_test_and_clear(state, &index);
}
return mac->channel[index];