Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch randint(upper_bound) to arc4random_uniform() if available #1754

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

michaelortmann
Copy link
Member

@michaelortmann michaelortmann commented Jan 31, 2025

Found by: michaelortmann
Patch by: michaelortmann
Fixes:

One-line summary:
Switch randint(upper_bound) to arc4random_uniform(upper_bound) if available

Additional description (if needed):
Switch also rand() % upper_bound and random() % upper_bound

This 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:

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.

Please run misc/runautotools when testing / merging this PR.

Test cases demonstrating functionality (if applicable):

Keep srandom(seed) also if we use arc4random*()

Update doc tcl-commands.rst

Add dietlibc hints to doc COMPILE-GUIDE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant