]> git.eshelyaron.com Git - emacs.git/commitdiff
unexecmacos.x (unexec_copy): Do not copy more than was requested (count)
authorSteven Tamm <steventamm@mac.com>
Wed, 28 Jan 2004 06:07:36 +0000 (06:07 +0000)
committerSteven Tamm <steventamm@mac.com>
Wed, 28 Jan 2004 06:07:36 +0000 (06:07 +0000)
to prevent overwriting during unexec.

src/ChangeLog
src/unexmacosx.c

index e4f53a22ee8f762e05bc42dc4f019aa47ef7b4e4..61711332b4c8c45a9cabed79964cac8981a5cae2 100644 (file)
@@ -1,3 +1,8 @@
+2004-01-27  Steven Tamm <steventamm@mac.com>
+
+       * unexmacosx.c (unexec_copy): Do not copy more than was
+       requested to prevent overwriting during unexec.
+
 2004-01-27  Jan Dj\e,Ad\e(Brv  <jan.h.d@swipnet.se>
 
        * process.c (sigchld_handler): Add comment about not calling malloc.
index b85323259731b9822462f190f13135c2652b21d7..b41c586d2e03999e315dc4001babe87c1528333d 100644 (file)
@@ -192,6 +192,7 @@ static int
 unexec_copy (off_t dest, off_t src, ssize_t count)
 {
   ssize_t bytes_read;
+  ssize_t bytes_to_read;
 
   char buf[UNEXEC_COPY_BUFSZ];
 
@@ -203,7 +204,8 @@ unexec_copy (off_t dest, off_t src, ssize_t count)
 
   while (count > 0)
     {
-      bytes_read = read (infd, buf, UNEXEC_COPY_BUFSZ);
+      bytes_to_read = count > UNEXEC_COPY_BUFSZ ? UNEXEC_COPY_BUFSZ : count;
+      bytes_read = read (infd, buf, bytes_to_read);
       if (bytes_read <= 0)
        return 0;
       if (write (outfd, buf, bytes_read) != bytes_read)