ImperialSpaceSociety / LoRaMac-node

Reference implementation and documentation of a LoRa network node.
Other
6 stars 1 forks source link

undefined behaviour possible with `rand_time_pos_index` #452

Closed MedadRufus closed 1 year ago

MedadRufus commented 1 year ago

This looks potentially problematic: https://github.com/ImperialSpaceSociety/LoRaMac-node/blob/fa1a6b613691f293d8ae41102fa9a3e05f1f2cf0/src/peripherals/playback.c#L127-L133

rand_time_pos_index may go out of range.

Fortunately, rand_time_pos_index is handled safely further downstream with a mod() function. Otherwise it could have caused problems. https://github.com/ImperialSpaceSociety/LoRaMac-node/blob/fa1a6b613691f293d8ae41102fa9a3e05f1f2cf0/src/peripherals/bsp.c#L610-L617

MedadRufus commented 1 year ago

this is not possible anymore, as the n_positions_saved_since_boot variable has been removed in #467