openbsd-ports/www/epiphany/patches/patch-lib_ephy-sync-utils_c
2020-07-04 07:20:33 +00:00

37 lines
943 B
Plaintext

$OpenBSD: patch-lib_ephy-sync-utils_c,v 1.3 2020/07/04 07:20:33 ajacoutot Exp $
Index: lib/ephy-sync-utils.c
--- lib/ephy-sync-utils.c.orig
+++ lib/ephy-sync-utils.c
@@ -30,7 +30,11 @@
#include <libsoup/soup.h>
#include <stdio.h>
#include <string.h>
+#if defined(__linux__)
#include <sys/random.h>
+#elif defined(__FreeBSD__) || defined(__OpenBSD__)
+#include <unistd.h>
+#endif
static const char hex_digits[] = "0123456789abcdef";
@@ -179,12 +183,18 @@ ephy_sync_utils_generate_random_bytes (void *random_
g_assert (num_bytes > 0);
g_assert (out);
+#ifdef __OpenBSD__
+ if (getentropy (out, num_bytes) == -1) {
+ g_error ("Failed to get entropy: %s", g_strerror (errno));
+ }
+#else
do {
ret = getrandom (out, num_bytes, 0);
} while (ret < (gssize)num_bytes && errno == EINTR);
if (ret != (gssize)num_bytes)
g_error ("Failed to generate randomness: %s", g_strerror (errno));
+#endif
}
char *