]> Git Repo - secp256k1.git/commitdiff
fix bug in fread() failure check
authorDon Viszneki <[email protected]>
Tue, 6 Mar 2018 02:45:00 +0000 (18:45 -0800)
committerDon Viszneki <[email protected]>
Tue, 6 Mar 2018 02:45:00 +0000 (18:45 -0800)
the two middle arguments to fread() are easily confused, and cause the
checking of return value to fail incorrectly (and possibly succeed
incorrectly.)

src/tests.c

index 05314572c0f91824d0d7ec092d3d1d002d98b7aa..67559ea0bdb5d73db6945cf14b9e8d6839b92454 100644 (file)
@@ -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;
This page took 0.032187 seconds and 4 git commands to generate.