Title: [188489] trunk/Source/WTF
- Revision
- 188489
- Author
- [email protected]
- Date
- 2015-08-14 15:01:34 -0700 (Fri, 14 Aug 2015)
Log Message
cryptographicallyRandomValuesFromOS should use arc4random_buf on Darwin.
https://bugs.webkit.org/show_bug.cgi?id=148038
Patch by Keith Miller <[email protected]> on 2015-08-14
Reviewed by Geoffrey Garen.
Currently, we open a file descriptor to /dev/urandom, which can sometimes
fail to open. Using arc4random_buf instead should get around this issue.
* wtf/OSRandomSource.cpp:
(WTF::cryptographicallyRandomValuesFromOS):
Modified Paths
Diff
Modified: trunk/Source/WTF/ChangeLog (188488 => 188489)
--- trunk/Source/WTF/ChangeLog 2015-08-14 21:55:58 UTC (rev 188488)
+++ trunk/Source/WTF/ChangeLog 2015-08-14 22:01:34 UTC (rev 188489)
@@ -1,3 +1,16 @@
+2015-08-14 Keith Miller <[email protected]>
+
+ cryptographicallyRandomValuesFromOS should use arc4random_buf on Darwin.
+ https://bugs.webkit.org/show_bug.cgi?id=148038
+
+ Reviewed by Geoffrey Garen.
+
+ Currently, we open a file descriptor to /dev/urandom, which can sometimes
+ fail to open. Using arc4random_buf instead should get around this issue.
+
+ * wtf/OSRandomSource.cpp:
+ (WTF::cryptographicallyRandomValuesFromOS):
+
2015-08-14 Commit Queue <[email protected]>
Unreviewed, rolling out r188444.
Modified: trunk/Source/WTF/wtf/OSRandomSource.cpp (188488 => 188489)
--- trunk/Source/WTF/wtf/OSRandomSource.cpp 2015-08-14 21:55:58 UTC (rev 188488)
+++ trunk/Source/WTF/wtf/OSRandomSource.cpp 2015-08-14 22:01:34 UTC (rev 188489)
@@ -29,7 +29,7 @@
#include <stdint.h>
#include <stdlib.h>
-#if OS(UNIX)
+#if !OS(DARWIN) && OS(UNIX)
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
@@ -42,6 +42,7 @@
namespace WTF {
+#if !OS(DARWIN) && OS(UNIX)
NEVER_INLINE NO_RETURN_DUE_TO_CRASH static void crashUnableToOpenURandom()
{
CRASH();
@@ -51,10 +52,13 @@
{
CRASH();
}
+#endif
void cryptographicallyRandomValuesFromOS(unsigned char* buffer, size_t length)
{
-#if OS(UNIX)
+#if OS(DARWIN)
+ return arc4random_buf(buffer, length);
+#elif OS(UNIX)
int fd = open("/dev/urandom", O_RDONLY, 0);
if (fd < 0)
crashUnableToOpenURandom(); // We need /dev/urandom for this API to work...
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes