Skip to content

Commit

Permalink
fix bug in fread() failure check
Browse files Browse the repository at this point in the history
the two middle arguments to fread() are easily confused, and cause the
checking of return value to fail incorrectly (and possibly succeed
incorrectly.)
  • Loading branch information
hdon committed Mar 6, 2018
1 parent cddef0c commit 8b3841c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -4918,7 +4918,7 @@ int main(int argc, char **argv) {
}
} else {
FILE *frand = fopen("/dev/urandom", "r");
if ((frand == NULL) || fread(&seed16, sizeof(seed16), 1, frand) != sizeof(seed16)) {
if ((frand == NULL) || fread(&seed16, 1, sizeof(seed16), frand) != sizeof(seed16)) {
fprintf(stderr, "WARNING: could not read 16 bytes from /dev/urandom; falling back to insecure PRNG\n");
uint64_t t = time(NULL) * (uint64_t)1337;
seed16[0] ^= t;
Expand Down

0 comments on commit 8b3841c

Please sign in to comment.