Skip to content

Commit

Permalink
Replaced library_fs.js/random_device()'s Math.random fallback call wi…
Browse files Browse the repository at this point in the history
…th throw for safety (#7096)

It should be a cryptographically secure function per POSIX (linux?), so error if none is available.
  • Loading branch information
paulshapiro authored and kripken committed Sep 5, 2018
1 parent 906e14e commit 6cc4c66
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -358,3 +358,4 @@ a license to everyone to use it as detailed in LICENSE.)
* Alexander Frank Lehmann <[email protected]> (copyright owned by Compusoft Group)
* Tommy Nguyen <[email protected]>
* Benjamin S. Rodgers <[email protected]>
* Paul Shapiro <[email protected]>
2 changes: 1 addition & 1 deletion src/library_fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -1301,7 +1301,7 @@ mergeInto(LibraryManager.library, {
#endif // ENVIRONMENT_MAY_BE_NODE
} else {
// default for ES5 platforms
random_device = function() { return (Math.random()*256)|0; };
random_device = function() { abort("random_device"); /*Math.random() is not safe for random number generation, so this fallback random_device implementation aborts... see kripken/emscripten/pull/7096 */ };
}
FS.createDevice('/dev', 'random', random_device);
FS.createDevice('/dev', 'urandom', random_device);
Expand Down

0 comments on commit 6cc4c66

Please sign in to comment.