aboutsummaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2003-06-17 20:19:41 +0000
committerNick Mathewson <nickm@torproject.org>2003-06-17 20:19:41 +0000
commit769c78a395b65e22bb8d55c41f1724a2b92491e7 (patch)
tree2e0eda9d17a35b0a26517f7b0a0fe14ede5b64d5 /src/common
parent05a8c264ff4bff8ea13596759b3a4f0ef153041d (diff)
downloadtor-769c78a395b65e22bb8d55c41f1724a2b92491e7.tar
tor-769c78a395b65e22bb8d55c41f1724a2b92491e7.tar.gz
Use fread instead of fgets for binary data
svn:r328
Diffstat (limited to 'src/common')
-rw-r--r--src/common/crypto.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/common/crypto.c b/src/common/crypto.c
index d3ef7a2c8..8a9dd86c3 100644
--- a/src/common/crypto.c
+++ b/src/common/crypto.c
@@ -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;
}