fread returns element count, not element size

This commit is contained in:
steven Y Gui 2021-07-14 16:17:48 +08:00
parent bd102eaa35
commit ffd35d8902

View File

@ -168,7 +168,7 @@ static long read_random_bytes (void)
#else #else
FILE *f = fopen ("/dev/urandom", "r"); FILE *f = fopen ("/dev/urandom", "r");
if (fread (&randval, sizeof (randval), 1, f) != sizeof (randval)) { if (fread (&randval, sizeof (randval), 1, f) != 1) {
fclose(f); fclose(f);
goto fail; goto fail;
} }