From 911c78b4aa114f17cc5388def3a026bb81c7e6a1 Mon Sep 17 00:00:00 2001 From: Steven Tamm Date: Wed, 28 Jan 2004 06:07:36 +0000 Subject: [PATCH] unexecmacos.x (unexec_copy): Do not copy more than was requested (count) to prevent overwriting during unexec. --- src/ChangeLog | 5 +++++ src/unexmacosx.c | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/ChangeLog b/src/ChangeLog index e4f53a22ee8..61711332b4c 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2004-01-27 Steven Tamm + + * unexmacosx.c (unexec_copy): Do not copy more than was + requested to prevent overwriting during unexec. + 2004-01-27 Jan Dj,Ad(Brv * 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 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) -- 2.39.2