brocaar / chirpstack-simulator

Simulator utility for the ChirpStack open-source LoRaWAN Network-Server.
https://www.chirpstack.io
MIT License
64 stars 51 forks source link

Fix invalid argument to mrand.Intn on 32-bit systems #6

Closed namedun closed 3 years ago

namedun commented 3 years ago

The int type are 32 bits wide on 32-bit systems in golang. Converting time.Duration to int on a 32-bit systems with the 'int(s.activationTime)' may cause the overflow. For example, for a duration '1m' (1 minute) the conversion to int should result in 600000000000000 (ns), exceeding 2^32. To avoid this conversion problem on 32-bit systems, we need to convert time.Duration to int64 type and use mrand.Int63n instead of mrand.Intn.

Fixes: #4

brocaar commented 3 years ago

Thanks! :+1: