From cf3be453002e2d404f4a2a993472fc0f7c211f6e Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Mon, 10 Apr 2017 02:41:54 +0000 Subject: [PATCH] Make cow position more random Patch from Tony Finch --- ChangeLog | 5 +++++ src/xcowsay.c | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 6040fd0..5be586a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2017-04-10 Nick Gasson + + * src/xcowsay.c (main): patch from Tony Finch to make cow + location more random. + 2016-09-08 Nick Gasson * configure.ac: updated to GNU gettext 0.19 and removed diff --git a/src/xcowsay.c b/src/xcowsay.c index 6c20211..b68e265 100644 --- a/src/xcowsay.c +++ b/src/xcowsay.c @@ -29,6 +29,7 @@ #include #include +#include #include #include @@ -330,7 +331,9 @@ int main(int argc, char **argv) if (failure) exit(EXIT_FAILURE); - srandom((unsigned)time(NULL)); + struct timeval tv; + gettimeofday(&tv, NULL); + srandom(tv.tv_sec ^ tv.tv_usec ^ getpid()); cowmode_t mode = think_flag ? COWMODE_THINK : COWMODE_NORMAL; -- 2.39.2