Skip to content

Commit ed5a199

Browse files
real-or-randomsipa
authored andcommitted
tests: fopen /dev/urandom in binary mode
This makes a difference with mingw builds on Wine, where the subsequent fread() may abort early in the default text mode. The Microsoft C docs say: "In text mode, CTRL+Z is interpreted as an EOF character on input."
1 parent 4dc37bf commit ed5a199

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/testrand_impl.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ static void secp256k1_testrand_init(const char* hexseed) {
127127
pos++;
128128
}
129129
} else {
130-
FILE *frand = fopen("/dev/urandom", "r");
130+
FILE *frand = fopen("/dev/urandom", "rb");
131131
if ((frand == NULL) || fread(&seed16, 1, sizeof(seed16), frand) != sizeof(seed16)) {
132132
uint64_t t = time(NULL) * (uint64_t)1337;
133133
fprintf(stderr, "WARNING: could not read 16 bytes from /dev/urandom; falling back to insecure PRNG\n");

0 commit comments

Comments
 (0)