diff --git a/plugins/autopair.c b/plugins/autopair.c
index 5d90f9d..5aa80df 100644
--- a/plugins/autopair.c
+++ b/plugins/autopair.c
#include <stdbool.h>
#include <stdlib.h>
+#include <fcntl.h>
+#include <unistd.h>
#include <bluetooth/bluetooth.h>
#include <glib.h>
static int autopair_init(void)
{
/* Initialize the random seed from /dev/urandom */
- unsigned int seed = time(NULL);
- FILE *f;
+ unsigned int seed;
+ int fd;
- f = fopen("/dev/urandom", "rb");
- if (f != NULL) {
- fread(&seed, sizeof(seed), 1, f);
- fclose(f);
- }
+ fd = open("/dev/urandom", O_RDONLY);
+ if (fd >= 0) {
+ ssize_t n;
+
+ n = read(fd, &seed, sizeof(seed));
+ if (n < (ssize_t) sizeof(seed))
+ seed = time(NULL);
+
+ close(fd);
+ } else
+ seed = time(NULL);
srand(seed);