Skip to content

UUID() does not produce proper UUIDs #3320

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

Closed
Tracked by #3040
ShonFrazier opened this issue Aug 2, 2021 · 6 comments
Closed
Tracked by #3040

UUID() does not produce proper UUIDs #3320

ShonFrazier opened this issue Aug 2, 2021 · 6 comments

Comments

@ShonFrazier
Copy link

Always produces 00000000-0000-4000-8000-000000000000. This may have been chosen at random (once), but lacks sufficient entropy.

@yonihemi
Copy link
Member

yonihemi commented Aug 3, 2021

I've had this happen several months ago but wasn't able to reproduce since. Can you share the setup your seeing this in?
Also, can you try adding import CoreFoundation and see if it work?

@ShonFrazier
Copy link
Author

when importing both Foundation and CoreFoundation I get the same output.

@kateinoigakukun
Copy link
Member

In WASI, /dev is not predefined and this line always fails to read the randomized content, so the buffer is always zero.
https://github.com/swiftwasm/swift-corelibs-foundation/blob/7cbab5eb4b2b9f0643c27801f35e591381e64d31/Sources/UUID/uuid.c#L93

We should use random_get WASI API instead of reading /dev/urandom

@ShonFrazier
Copy link
Author

if there's a TARGET_OS_WASI, probably just needs to be OR'd with Windows

@kateinoigakukun
Copy link
Member

Resolved by swiftwasm/swift-corelibs-foundation#323

@MaxDesiatov
Copy link

TWIMC, the fix has been included in SwiftWasm 5.4.0

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

No branches or pull requests

4 participants