Crypto: RandInRange() fails to stay within range when using signed or unsigned integers
Created by: anonimal
For example:
int port = i2p::crypto::RandInRange<int>(9111, 30777);
When looped, will produce the following:
4835
12969
12302
-7772
-9926
-10952
6444
20583
29331
609
22397
...etc.
For the time being, using any unsigned int appears to be fine. We currently do not use any signed int's for RandInRange()
but this issue is quite dangerous because this caveat is undocumented/(code is unfinished?) so, should we ever need signed int's with RandInRange()
in critical code...