Skip to content
Snippets Groups Projects
Commit 769c78a3 authored by Nick Mathewson's avatar Nick Mathewson :game_die:
Browse files

Use fread instead of fgets for binary data

svn:r328
parent 05a8c264
No related branches found
No related tags found
No related merge requests found
......@@ -792,9 +792,8 @@ int crypto_seed_rng()
static char *filenames[] = {
"/dev/srandom", "/dev/urandom", "/dev/random", NULL
};
int i;
int i, n;
char buf[21];
char *cp;
FILE *f;
for (i = 0; filenames[i]; ++i) {
......@@ -802,9 +801,9 @@ int crypto_seed_rng()
if (!f) continue;
log(LOG_INFO, "Seeding RNG from %s", filenames[i]);
buf[20]='\xff';
cp = fgets(buf, 20, f);
n = fread(buf, 1, 20, f);
fclose(f);
if (!cp || buf[20]) {
if (n != 20) {
log(LOG_INFO, "Error reading from entropy source");
return -1;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment