[riot-notifications] [RIOT-OS/RIOT] net/gnrc_lorawan: fix random_uint32_range upper bound (#16664)

Leandro Lanzieri notifications at github.com
Wed Jul 21 08:53:47 CEST 2021


@leandrolanzieri commented on this pull request.



> @@ -100,7 +100,7 @@ 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 random_number = random_uint32_range(0, bitarithm_bits_set(mac->channel_mask) + 1);

Is for some reason `mac->channel[0]` always valid? Because when `random_number == 0` that's the chosen one.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/16664#pullrequestreview-711312939
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20210720/32f9dd3b/attachment.htm>


More information about the notifications mailing list