| 87 | return p; |
| 88 | } |
| 89 | |
| 90 | static char *xstrdup(const char *s) { |
| 91 | size_t n = strlen(s); |
| 92 | char *p = xmalloc(n + 1); |
| 93 | memcpy(p, s, n + 1); |
| 94 | return p; |
| 95 | } |
| 96 | |
| 97 | static bool random_bytes(void *dst, size_t len) { |
| 98 | unsigned char *p = dst; |
| 99 | int fd = open("/dev/urandom", O_RDONLY); |
| 100 | if (fd < 0) return false; |
| 101 | while (len) { |
| 102 | ssize_t n = read(fd, p, len); |
| 103 | if (n < 0 && errno == EINTR) continue; |
| 104 | if (n <= 0) { |
| 105 | close(fd); |
| 106 | return false; |
| 107 | } |
| 108 | p += (size_t)n; |
no outgoing calls
no test coverage detected