aboutsummaryrefslogtreecommitdiffstats
path: root/src/process.c
diff options
context:
space:
mode:
authorPaul Eggert2013-06-22 09:43:39 -0700
committerPaul Eggert2013-06-22 09:43:39 -0700
commitf86852b4a3c34213f93fc5de5cb1632b49962023 (patch)
tree282f4ef9f968616b8dee2a91f07c320cf466c681 /src/process.c
parent12adebe94e4026ce2fb961f87a5790ec7693ae94 (diff)
downloademacs-f86852b4a3c34213f93fc5de5cb1632b49962023.tar.gz
emacs-f86852b4a3c34213f93fc5de5cb1632b49962023.zip
* process.c (wait_reading_process_output): Avoid int overflow
when reading more than 2 GiB total from a process.
Diffstat (limited to 'src/process.c')
-rw-r--r--src/process.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/process.c b/src/process.c
index c61a22c4beb..0631cb732bf 100644
--- a/src/process.c
+++ b/src/process.c
@@ -4430,7 +4430,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4430 && ! EQ (wait_proc->status, Qrun) 4430 && ! EQ (wait_proc->status, Qrun)
4431 && ! EQ (wait_proc->status, Qconnect)) 4431 && ! EQ (wait_proc->status, Qconnect))
4432 { 4432 {
4433 int nread, total_nread = 0; 4433 bool read_some_bytes = 0;
4434 4434
4435 clear_waiting_for_input (); 4435 clear_waiting_for_input ();
4436 XSETPROCESS (proc, wait_proc); 4436 XSETPROCESS (proc, wait_proc);
@@ -4438,16 +4438,13 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4438 /* Read data from the process, until we exhaust it. */ 4438 /* Read data from the process, until we exhaust it. */
4439 while (wait_proc->infd >= 0) 4439 while (wait_proc->infd >= 0)
4440 { 4440 {
4441 nread = read_process_output (proc, wait_proc->infd); 4441 int nread = read_process_output (proc, wait_proc->infd);
4442 4442
4443 if (nread == 0) 4443 if (nread == 0)
4444 break; 4444 break;
4445 4445
4446 if (nread > 0) 4446 if (nread > 0)
4447 { 4447 got_some_input = read_some_bytes = 1;
4448 total_nread += nread;
4449 got_some_input = 1;
4450 }
4451 else if (nread == -1 && (errno == EIO || errno == EAGAIN)) 4448 else if (nread == -1 && (errno == EIO || errno == EAGAIN))
4452 break; 4449 break;
4453#ifdef EWOULDBLOCK 4450#ifdef EWOULDBLOCK
@@ -4455,7 +4452,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4455 break; 4452 break;
4456#endif 4453#endif
4457 } 4454 }
4458 if (total_nread > 0 && do_display) 4455 if (read_some_bytes && do_display)
4459 redisplay_preserve_echo_area (10); 4456 redisplay_preserve_echo_area (10);
4460 4457
4461 break; 4458 break;