We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8a78b0e commit e7bf61dCopy full SHA for e7bf61d
src/libmongoc/src/mongoc/mongoc-rand-openssl.c
@@ -28,6 +28,18 @@
28
int
29
_mongoc_rand_bytes (uint8_t *buf, int num)
30
{
31
+#if OPENSSL_VERSION_NUMBER < 0x10101000L
32
+ /* Versions of OpenSSL before 1.1.1 can potentially produce the same random
33
+ * sequences in processes with the same PID. Rather than attempt to detect
34
+ * PID changes (useful for parent/child forking but not if PIDs wrap), mix
35
+ * the current time into the generator's state.
36
+ * See also: https://wiki.openssl.org/index.php/Random_fork-safety */
37
+ struct timeval tv;
38
+
39
+ bson_gettimeofday (&tv);
40
+ RAND_add (&tv, sizeof(tv), 0.0);
41
+#endif
42
43
return RAND_bytes (buf, num);
44
}
45
0 commit comments