changeset 53737:349eb7d143cf

unexecmacos.x (unexec_copy): Do not copy more than was requested (count) to prevent overwriting during unexec.
author Steven Tamm <steventamm@mac.com>
date Wed, 28 Jan 2004 06:07:36 +0000
parents df8ff5ff116d
children db94fc6b4b22
files src/ChangeLog src/unexmacosx.c
diffstat 2 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Tue Jan 27 23:08:29 2004 +0000
+++ b/src/ChangeLog	Wed Jan 28 06:07:36 2004 +0000
@@ -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,Ad(Brv  <jan.h.d@swipnet.se>
 
 	* process.c (sigchld_handler): Add comment about not calling malloc.
--- a/src/unexmacosx.c	Tue Jan 27 23:08:29 2004 +0000
+++ b/src/unexmacosx.c	Wed Jan 28 06:07:36 2004 +0000
@@ -192,6 +192,7 @@
 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 @@
 
   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)