Permalink
Browse files

Make cow position more random

Patch from Tony Finch
1 parent 356a820 commit cf3be453002e2d404f4a2a993472fc0f7c211f6e @nickg committed Apr 10, 2017
Showing with 9 additions and 1 deletion.
  1. +5 −0 ChangeLog
  2. +4 −1 src/xcowsay.c
View
@@ -1,3 +1,8 @@
+2017-04-10 Nick Gasson <nick@nickg.me.uk>
+
+ * src/xcowsay.c (main): patch from Tony Finch to make cow
+ location more random.
+
2016-09-08 Nick Gasson <nick@nickg.me.uk>
* configure.ac: updated to GNU gettext 0.19 and removed
View
@@ -29,6 +29,7 @@
#include <limits.h>
#include <sys/types.h>
+#include <sys/time.h>
#include <unistd.h>
#include <errno.h>
@@ -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;

0 comments on commit cf3be45

Please sign in to comment.