toplev.c (init_local_tick): Process the failure when read fails for random_seed.
authorChen Gang <gang.chen.5i5j@gmail.com>
Thu, 22 Jan 2015 16:40:51 +0000 (16:40 +0000)
committerJeff Law <law@gcc.gnu.org>
Thu, 22 Jan 2015 16:40:51 +0000 (09:40 -0700)
* toplev.c (init_local_tick): Process the failure when read
fails for random_seed.

From-SVN: r220006

gcc/ChangeLog
gcc/toplev.c

index b636b51d022274f7c3da3df5726459259a15b5ab..aeddcb8e66ecb4db49a041f1950673fb0e9cb8fa 100644 (file)
@@ -1,5 +1,8 @@
 2015-01-23  Chen Gang  <gang.chen.5i5j@gmail.com>
 
+       * toplev.c (init_local_tick): Process the failure when read
+       fails for random_seed.
+
        * ubsan.c (ubsan_type_descriptor): Use 'pretty_print' for
        'pretty_name' to avoid memory overflow.
 
index 7bf177fa970538a57d8a24d6cd4d31ef2b311c86..15b85e1d2e917f4118cded035cea1e307e1798e2 100644 (file)
@@ -295,7 +295,9 @@ init_local_tick (void)
       int fd = open ("/dev/urandom", O_RDONLY);
       if (fd >= 0)
         {
-          read (fd, &random_seed, sizeof (random_seed));
+          if (read (fd, &random_seed, sizeof (random_seed))
+              != sizeof (random_seed))
+            random_seed = 0;
           close (fd);
         }