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

Fallback to srand/rand if srandom/random are missing #395

Merged
merged 2 commits into from
Jul 24, 2023
Merged

Fallback to srand/rand if srandom/random are missing #395

merged 2 commits into from
Jul 24, 2023

Conversation

scribam
Copy link
Contributor

@scribam scribam commented Jul 23, 2023

From #156

  1. srandom and random are POSIX extensions not present on non-POSIX
    platforms, replace them with srand and rand respectively. They
    might produce different results, but that shouldn't matter in the
    context of the caller, which is the non-secure version

uwp and win32 already use these functions, we can unify all platforms with these changes

vitasdk (a sdk for playstation vita) has the same patch (https://github.com/vitasdk/packages/blob/master/libzip/random.patch) in order to build libzip and I would like to remove it :)

@dillof
Copy link
Member

dillof commented Jul 24, 2023

IIRC, some systems have deprecation warning for rand(). I'd therefore prefer to have cmake check for the existence of random() and only fall back to rand() if it's missing.

Also, while reading the diff, I just noticed that we never set seeded to true. Could you please add this, so we avoid conflicts?

@scribam scribam changed the title Replace srandom/random by srand/rand Fallback to srand/rand if srandom/random are missing Jul 24, 2023
@dillof dillof merged commit 3a61d6a into nih-at:main Jul 24, 2023
1 check passed
@scribam scribam deleted the rand branch July 24, 2023 13:07
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.

2 participants