diff src/unexmacosx.c @ 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 d9dc58d31ffb
children 8434603cae5b
line wrap: on
line diff
--- 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)