Skip to content

Commit 234fa0a

Browse files
committed
Use /dev/urandom for generating uuid instead of /dev/random
1 parent c41d50d commit 234fa0a

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

uuid/uuid.c

+6-13
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,6 @@
4848
#include <net/if_dl.h>
4949
#include <net/if_types.h>
5050

51-
static inline void read_random(void *buffer, u_int numBytes) {
52-
int fd = open("/dev/random", O_RDONLY);
53-
read(fd, buffer, numBytes);
54-
close(fd);
55-
}
56-
5751
static inline void nanotime(struct timespec *tv) {
5852
uint64_t now = mach_absolute_time();
5953
tv->tv_sec = now / 1000000000;
@@ -63,19 +57,18 @@ static inline void nanotime(struct timespec *tv) {
6357
#elif TARGET_OS_LINUX
6458
#include <time.h>
6559

66-
67-
static inline void read_random(void *buffer, u_int numBytes) {
68-
int fd = open("/dev/random", O_RDONLY);
69-
read(fd, buffer, numBytes);
70-
close(fd);
71-
}
72-
7360
static inline void nanotime(struct timespec *tv) {
7461
clock_gettime(CLOCK_MONOTONIC, tv);
7562
}
7663

7764
#endif
7865

66+
static inline void read_random(void *buffer, u_int numBytes) {
67+
int fd = open("/dev/urandom", O_RDONLY);
68+
read(fd, buffer, numBytes);
69+
close(fd);
70+
}
71+
7972

8073
UUID_DEFINE(UUID_NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
8174

0 commit comments

Comments
 (0)