From 253f3e57386cea5b4877a92d11038f9b6ad0444d Mon Sep 17 00:00:00 2001 From: Curt Wohlgemuth Date: Thu, 18 Oct 2007 10:45:55 -0600 Subject: [PATCH] [Linux] Fix potentially overlapping memory-copy to use memmove() instead of memcpy(). --- src/os-linux.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/os-linux.h b/src/os-linux.h index 57c57231..b2c9a8be 100644 --- a/src/os-linux.h +++ b/src/os-linux.h @@ -228,7 +228,7 @@ maps_next (struct map_iterator *mi, { /* copy down the remaining bytes, if any */ if (bytes_left > 0) - memcpy (mi->buf_end - mi->buf_size, mi->buf, bytes_left); + memmove (mi->buf_end - mi->buf_size, mi->buf, bytes_left); mi->buf = mi->buf_end - mi->buf_size; nread = read (mi->fd, mi->buf + bytes_left, @@ -240,7 +240,7 @@ maps_next (struct map_iterator *mi, /* Move contents to the end of the buffer so we maintain the invariant that all bytes between mi->buf and mi->buf_end are valid. */ - memcpy (mi->buf_end - nread - bytes_left, mi->buf, + memmove (mi->buf_end - nread - bytes_left, mi->buf, nread + bytes_left); mi->buf = mi->buf_end - nread - bytes_left; }