diff options
Diffstat (limited to 'src/basic')
-rw-r--r-- | src/basic/random-util.c | 15 | ||||
-rw-r--r-- | src/basic/terminal-util.c | 4 |
2 files changed, 9 insertions, 10 deletions
diff --git a/src/basic/random-util.c b/src/basic/random-util.c index e1543da5a3..2f468db770 100644 --- a/src/basic/random-util.c +++ b/src/basic/random-util.c @@ -95,17 +95,18 @@ void initialize_srand(void) { if (srand_called) return; - x = 0; - #ifdef HAVE_SYS_AUXV_H - /* The kernel provides us with a bit of entropy in auxv, so - * let's try to make use of that to seed the pseudo-random - * generator. It's better than nothing... */ + /* The kernel provides us with 16 bytes of entropy in auxv, so let's try to make use of that to seed the + * pseudo-random generator. It's better than nothing... */ auxv = (void*) getauxval(AT_RANDOM); - if (auxv) - x ^= *(unsigned*) auxv; + if (auxv) { + assert_cc(sizeof(x) < 16); + memcpy(&x, auxv, sizeof(x)); + } else #endif + x = 0; + x ^= (unsigned) now(CLOCK_REALTIME); x ^= (unsigned) gettid(); diff --git a/src/basic/terminal-util.c b/src/basic/terminal-util.c index fedfc8a5df..0a9d2bbdef 100644 --- a/src/basic/terminal-util.c +++ b/src/basic/terminal-util.c @@ -726,9 +726,7 @@ bool tty_is_vc_resolve(const char *tty) { } const char *default_term_for_tty(const char *tty) { - assert(tty); - - return tty_is_vc_resolve(tty) ? "TERM=linux" : "TERM=vt220"; + return tty && tty_is_vc_resolve(tty) ? "TERM=linux" : "TERM=vt220"; } int fd_columns(int fd) { |