aboutsummaryrefslogtreecommitdiff
path: root/src/math
diff options
context:
space:
mode:
Diffstat (limited to 'src/math')
-rw-r--r--src/math/random.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/math/random.c b/src/math/random.c
index 94197fe..a1d88ab 100644
--- a/src/math/random.c
+++ b/src/math/random.c
@@ -11,7 +11,11 @@ bool random_init(void) {
// Try urandom first
FILE *rand = fopen("/dev/urandom", "rb");
if (rand) {
- fread(&seed, 1, sizeof(pari_ulong), rand);
+ size_t read = 0;
+ while (read < sizeof(pari_ulong)) {
+ read += fread(&seed + read, 1, sizeof(pari_ulong) - read, rand);
+ }
+
fclose(rand);
}
// Try worse methods later