* toplev.c (init_local_tick): Process the failure when read
authorlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 22 Jan 2015 16:40:51 +0000 (16:40 +0000)
committerlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 22 Jan 2015 16:40:51 +0000 (16:40 +0000)
fails for random_seed.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@220006 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/toplev.c

index b636b51..aeddcb8 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 7bf177f..15b85e1 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);
         }