]> git.eshelyaron.com Git - emacs.git/commitdiff
* process.c (wait_reading_process_output): Avoid int overflow
authorPaul Eggert <eggert@cs.ucla.edu>
Sat, 22 Jun 2013 16:43:39 +0000 (09:43 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sat, 22 Jun 2013 16:43:39 +0000 (09:43 -0700)
when reading more than 2 GiB total from a process.

src/ChangeLog
src/process.c

index bdb8baf65d847207fd28f8a2b0a52474a79b57b6..36709eb51073e1342ebf9cfb6dd340c7e7d76848 100644 (file)
@@ -1,3 +1,8 @@
+2013-06-22  Paul Eggert  <eggert@cs.ucla.edu>
+
+       * process.c (wait_reading_process_output): Avoid int overflow
+       when reading more than 2 GiB total from a process.
+
 2013-06-21  Paul Eggert  <eggert@cs.ucla.edu>
 
        * process.c (create_process): Handle a couple more cases,
index c61a22c4bebbc3c3f4510164de9aec2144bc04e4..0631cb732bfa6bc86db47ec4d993a30d8d04e035 100644 (file)
@@ -4430,7 +4430,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
          && ! EQ (wait_proc->status, Qrun)
          && ! EQ (wait_proc->status, Qconnect))
        {
-         int nread, total_nread = 0;
+         bool read_some_bytes = 0;
 
          clear_waiting_for_input ();
          XSETPROCESS (proc, wait_proc);
@@ -4438,16 +4438,13 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
          /* Read data from the process, until we exhaust it.  */
          while (wait_proc->infd >= 0)
            {
-             nread = read_process_output (proc, wait_proc->infd);
+             int nread = read_process_output (proc, wait_proc->infd);
 
              if (nread == 0)
                break;
 
              if (nread > 0)
-               {
-                 total_nread += nread;
-                 got_some_input = 1;
-               }
+               got_some_input = read_some_bytes = 1;
              else if (nread == -1 && (errno == EIO || errno == EAGAIN))
                break;
 #ifdef EWOULDBLOCK
@@ -4455,7 +4452,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
                break;
 #endif
            }
-         if (total_nread > 0 && do_display)
+         if (read_some_bytes && do_display)
            redisplay_preserve_echo_area (10);
 
          break;