b2a9b0
commit e1df30fbc2e2167a982c0e77a7ebee28f4dd0800
b2a9b0
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
b2a9b0
Date:   Thu Jul 25 11:22:17 2019 -0300
b2a9b0
b2a9b0
    Get new entropy on each attempt __gen_tempname (BZ #15813)
b2a9b0
    
b2a9b0
    This is missing bit for fully fix BZ#15813 (the other two were fixed
b2a9b0
    by 359653aaacad463).
b2a9b0
    
b2a9b0
    Checked on x86_64-linux-gnu.
b2a9b0
    
b2a9b0
            [BZ #15813]
b2a9b0
            sysdeps/posix/tempname.c (__gen_tempname): get entrypy on each
b2a9b0
            attempt.
b2a9b0
b2a9b0
diff --git a/sysdeps/posix/tempname.c b/sysdeps/posix/tempname.c
b2a9b0
index 3d26f378021680ae..61d7a9f36d37abae 100644
b2a9b0
--- a/sysdeps/posix/tempname.c
b2a9b0
+++ b/sysdeps/posix/tempname.c
b2a9b0
@@ -186,7 +186,6 @@ __gen_tempname (char *tmpl, int suffixlen, int flags, int kind)
b2a9b0
 {
b2a9b0
   int len;
b2a9b0
   char *XXXXXX;
b2a9b0
-  uint64_t value;
b2a9b0
   unsigned int count;
b2a9b0
   int fd = -1;
b2a9b0
   int save_errno = errno;
b2a9b0
@@ -218,13 +217,13 @@ __gen_tempname (char *tmpl, int suffixlen, int flags, int kind)
b2a9b0
   /* This is where the Xs start.  */
b2a9b0
   XXXXXX = &tmpl[len - 6 - suffixlen];
b2a9b0
 
b2a9b0
-  /* Get some more or less random data.  */
b2a9b0
-  RANDOM_BITS (value);
b2a9b0
-  value ^= (uint64_t)__getpid () << 32;
b2a9b0
-
b2a9b0
-  for (count = 0; count < attempts; value += 7777, ++count)
b2a9b0
+  uint64_t pid = (uint64_t) __getpid () << 32;
b2a9b0
+  for (count = 0; count < attempts; ++count)
b2a9b0
     {
b2a9b0
-      uint64_t v = value;
b2a9b0
+      uint64_t v;
b2a9b0
+      /* Get some more or less random data.  */
b2a9b0
+      RANDOM_BITS (v);
b2a9b0
+      v ^= pid;
b2a9b0
 
b2a9b0
       /* Fill in the random bits.  */
b2a9b0
       XXXXXX[0] = letters[v % 62];