From b25d5fcdcf4723ca3da8bc69ecc6c52010778f7c Mon Sep 17 00:00:00 2001 From: Mark Adler Date: Thu, 12 Oct 2017 19:34:51 -0700 Subject: [PATCH] Avoid undefined behaviors of memcpy() in gz*printf(). --- gzwrite.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gzwrite.c b/gzwrite.c index 3560193..26e89b6 100644 --- a/gzwrite.c +++ b/gzwrite.c @@ -444,7 +444,7 @@ int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) strm->avail_in = state->size; if (gz_comp(state, Z_NO_FLUSH) == -1) return state->err; - memcpy(state->in, state->in + state->size, left); + memmove(state->in, state->in + state->size, left); strm->next_in = state->in; strm->avail_in = left; } @@ -543,7 +543,7 @@ int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, strm->avail_in = state->size; if (gz_comp(state, Z_NO_FLUSH) == -1) return state->err; - memcpy(state->in, state->in + state->size, left); + memmove(state->in, state->in + state->size, left); strm->next_in = state->in; strm->avail_in = left; }