Switch randint(upper_bound) to arc4random_uniform() if available#1754
Open
michaelortmann wants to merge 4 commits into
Open
Switch randint(upper_bound) to arc4random_uniform() if available#1754michaelortmann wants to merge 4 commits into
michaelortmann wants to merge 4 commits into
Conversation
Keep srandom(seed) also if we use arc4random*() Update doc tcl-commands.rst Add dietlibc hints to doc COMPILE-GUIDE
2689092 to
4a13def
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Found by: michaelortmann
Patch by: michaelortmann
Fixes:
One-line summary:
Switch
randint(upper_bound)toarc4random_uniform(upper_bound)if availableAdditional description (if needed):
Switch also
rand() % upper_boundandrandom() % upper_boundThis PR not only enables good random numbers within eggdrop, but also cleans up a lot of legacy and fragile code (behind ifdefs for systems that dont have arc4random)
A bit of recent history:
arc4random()based ongetrandom()invDSOhttps://www.phoronix.com/news/Linux-getrandom-vDSOarc4random()Finally all major operating systems and libcs support it, even cygwin, dietlibc and musl.
arc4random_*()became the defacto standard for (secure) random numbers.While at it, i added 2 dietlibc hints to COMPILE-GUIDE.
Test cases demonstrating functionality (if applicable):