From 1d5d50463c91beab8304e58bbd191144bb1b2ab8 Mon Sep 17 00:00:00 2001 From: Marian Beermann Date: Fri, 9 Jun 2017 11:21:50 +0200 Subject: [PATCH] hashindex_compact: use memmove for possibly overlapping copy --- src/borg/_hashindex.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/borg/_hashindex.c b/src/borg/_hashindex.c index 1fb30c0fa..8ed95b741 100644 --- a/src/borg/_hashindex.c +++ b/src/borg/_hashindex.c @@ -650,7 +650,8 @@ hashindex_compact(HashIndex *index) begin_used_idx = idx; if(!empty_slot_count) { - memcpy(BUCKET_ADDR(index, compact_tail_idx), BUCKET_ADDR(index, idx), index->bucket_size); + /* In case idx==compact_tail_idx, the areas overlap */ + memmove(BUCKET_ADDR(index, compact_tail_idx), BUCKET_ADDR(index, idx), index->bucket_size); idx++; compact_tail_idx++; continue;