aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSteven Tamm2004-01-28 06:07:36 +0000
committerSteven Tamm2004-01-28 06:07:36 +0000
commit911c78b4aa114f17cc5388def3a026bb81c7e6a1 (patch)
tree0c5fd9d53f7fe0dcefa3e51b4ea7476f745e06fc /src
parent92c7831bff66ec6f4cc6be6687ab1bf0b00033d2 (diff)
downloademacs-911c78b4aa114f17cc5388def3a026bb81c7e6a1.tar.gz
emacs-911c78b4aa114f17cc5388def3a026bb81c7e6a1.zip
unexecmacos.x (unexec_copy): Do not copy more than was requested (count)
to prevent overwriting during unexec.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog5
-rw-r--r--src/unexmacosx.c4
2 files changed, 8 insertions, 1 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index e4f53a22ee8..61711332b4c 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
12004-01-27 Steven Tamm <steventamm@mac.com>
2
3 * unexmacosx.c (unexec_copy): Do not copy more than was
4 requested to prevent overwriting during unexec.
5
12004-01-27 Jan Dj,Ad(Brv <jan.h.d@swipnet.se> 62004-01-27 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
2 7
3 * process.c (sigchld_handler): Add comment about not calling malloc. 8 * process.c (sigchld_handler): Add comment about not calling malloc.
diff --git a/src/unexmacosx.c b/src/unexmacosx.c
index b8532325973..b41c586d2e0 100644
--- a/src/unexmacosx.c
+++ b/src/unexmacosx.c
@@ -192,6 +192,7 @@ static int
192unexec_copy (off_t dest, off_t src, ssize_t count) 192unexec_copy (off_t dest, off_t src, ssize_t count)
193{ 193{
194 ssize_t bytes_read; 194 ssize_t bytes_read;
195 ssize_t bytes_to_read;
195 196
196 char buf[UNEXEC_COPY_BUFSZ]; 197 char buf[UNEXEC_COPY_BUFSZ];
197 198
@@ -203,7 +204,8 @@ unexec_copy (off_t dest, off_t src, ssize_t count)
203 204
204 while (count > 0) 205 while (count > 0)
205 { 206 {
206 bytes_read = read (infd, buf, UNEXEC_COPY_BUFSZ); 207 bytes_to_read = count > UNEXEC_COPY_BUFSZ ? UNEXEC_COPY_BUFSZ : count;
208 bytes_read = read (infd, buf, bytes_to_read);
207 if (bytes_read <= 0) 209 if (bytes_read <= 0)
208 return 0; 210 return 0;
209 if (write (outfd, buf, bytes_read) != bytes_read) 211 if (write (outfd, buf, bytes_read) != bytes_read)