Skip to content

Commit

Permalink
Avoid undefined behaviors of memcpy() in gz*printf().
Browse files Browse the repository at this point in the history
  • Loading branch information
madler committed Oct 13, 2017
1 parent ae49d14 commit b25d5fc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions gzwrite.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit b25d5fc

Please sign in to comment.