aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Tay <nick@windblume.net>2021-12-02 18:10:16 +1100
committerNicholas Tay <nick@windblume.net>2021-12-02 18:10:16 +1100
commit6570d30f963be94189cf8ed0bf0b751f28bd0051 (patch)
tree08058771195d6868a5b88060659a6afb3d60ede6
parentf3e1a6389ca1df7caf66072d676b9e53843deb3b (diff)
downloadpassgen-6570d30f963be94189cf8ed0bf0b751f28bd0051.tar.gz
passgen-6570d30f963be94189cf8ed0bf0b751f28bd0051.tar.bz2
passgen-6570d30f963be94189cf8ed0bf0b751f28bd0051.zip
Less syscalls the better? Call getrandom() every generation
Seems to hang every few executions if we getrandom one big chunk. Probably not enough entropy?
Diffstat (limited to '')
-rw-r--r--passgen.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/passgen.c b/passgen.c
index 3f1e59e..2c560b0 100644
--- a/passgen.c
+++ b/passgen.c
@@ -56,11 +56,7 @@ int main(int argc, char *argv[])
char password[grammar_size+1];
password[grammar_size] = 0;
-#ifdef __linux__
- // Reduce syscalls by generating a bunch and then doing it
- unsigned int entropy[grammar_size];
- getrandom(&entropy, sizeof(entropy), 0);
-#else
+#ifndef __linux__
// seed RNG; this isn't very good, but it's enough(?)
srand(time(NULL) + getpid() % 420 - 69);
#endif
@@ -87,7 +83,8 @@ int main(int argc, char *argv[])
do {
#ifdef __linux__
- unsigned int r = entropy[i];
+ unsigned int r;
+ getrandom(&r, sizeof(r), 0);
#else
long r = rand();
#endif