diff options
author | Steven Tamm <steventamm@mac.com> | 2004-01-28 06:07:36 +0000 |
---|---|---|
committer | Steven Tamm <steventamm@mac.com> | 2004-01-28 06:07:36 +0000 |
commit | 911c78b4aa114f17cc5388def3a026bb81c7e6a1 (patch) | |
tree | 0c5fd9d53f7fe0dcefa3e51b4ea7476f745e06fc /src/unexmacosx.c | |
parent | 92c7831bff66ec6f4cc6be6687ab1bf0b00033d2 (diff) | |
download | emacs-911c78b4aa114f17cc5388def3a026bb81c7e6a1.tar.gz emacs-911c78b4aa114f17cc5388def3a026bb81c7e6a1.tar.bz2 emacs-911c78b4aa114f17cc5388def3a026bb81c7e6a1.zip |
unexecmacos.x (unexec_copy): Do not copy more than was requested (count)
to prevent overwriting during unexec.
Diffstat (limited to 'src/unexmacosx.c')
-rw-r--r-- | src/unexmacosx.c | 4 |
1 files changed, 3 insertions, 1 deletions
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 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) |