|
@@ -0,0 +1,47 @@
|
|
|
+# HG changeset patch
|
|
|
+# User Bill Gianopoulos <wgianopoulos@gmail.com>
|
|
|
+# Date 1570452567 14400
|
|
|
+# Mon Oct 07 08:49:27 2019 -0400
|
|
|
+# Node ID 45bcb7edc9c43f687eb73116b2023cf793737228
|
|
|
+# Parent 3eec4b8d3eed8bdd316fdc4e4a10e04e834ec130
|
|
|
+No bug - Increase backwards compatibility by avoiding use of getentropy.
|
|
|
+
|
|
|
+diff --git a/security/nss/lib/freebl/unix_urandom.c b/security/nss/lib/freebl/unix_urandom.c
|
|
|
+--- a/security/nss/lib/freebl/unix_urandom.c
|
|
|
++++ b/security/nss/lib/freebl/unix_urandom.c
|
|
|
+@@ -28,16 +28,17 @@ RNG_SystemInfoForRNG(void)
|
|
|
+ size_t
|
|
|
+ RNG_SystemRNG(void *dest, size_t maxLen)
|
|
|
+ {
|
|
|
+ int fd;
|
|
|
+ int bytes;
|
|
|
+ size_t fileBytes = 0;
|
|
|
+ unsigned char *buffer = dest;
|
|
|
+
|
|
|
++#if 0
|
|
|
+ #if defined(__OpenBSD__) || (defined(__FreeBSD__) && __FreeBSD_version >= 1200000) || (defined(LINUX) && defined(__GLIBC__) && ((__GLIBC__ > 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 25))))
|
|
|
+ int result;
|
|
|
+
|
|
|
+ while (fileBytes < maxLen) {
|
|
|
+ size_t getBytes = maxLen - fileBytes;
|
|
|
+ if (getBytes > GETENTROPY_MAX_BYTES) {
|
|
|
+ getBytes = GETENTROPY_MAX_BYTES;
|
|
|
+ }
|
|
|
+@@ -57,16 +58,17 @@ RNG_SystemRNG(void *dest, size_t maxLen)
|
|
|
+ if (errno != ENOSYS) {
|
|
|
+ PORT_SetError(SEC_ERROR_NEED_RANDOM);
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ /* ENOSYS means the kernel doesn't support getentropy()/getrandom().
|
|
|
+ * Reset the number of bytes to get and fall back to /dev/urandom. */
|
|
|
+ fileBytes = 0;
|
|
|
+ #endif
|
|
|
++#endif
|
|
|
+ fd = open("/dev/urandom", O_RDONLY);
|
|
|
+ if (fd < 0) {
|
|
|
+ PORT_SetError(SEC_ERROR_NEED_RANDOM);
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ while (fileBytes < maxLen) {
|
|
|
+ bytes = read(fd, buffer, maxLen - fileBytes);
|
|
|
+ if (bytes <= 0) {
|