From: Timo Sirainen Date: Mon, 28 Feb 2022 19:43:27 +0000 (-0500) Subject: anvil: Use memmove() for moving penalty checksum buffer X-Git-Tag: 2.4.0~3763 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f21622505de656560c55cd30ce3d1e2c030ada4f;p=thirdparty%2Fdovecot%2Fcore.git anvil: Use memmove() for moving penalty checksum buffer The memory wasn't actually overlapping, because CHECKSUM_VALUE_COUNT=2 so only 1 element was memcpy()d. However, it would have been wrong if CHECKSUM_VALUE_COUNT had been higher, so fix it to make the code future-safe. Found by Martin Strunz --- diff --git a/src/anvil/penalty.c b/src/anvil/penalty.c index 3776b96f05..30c0a7bc17 100644 --- a/src/anvil/penalty.c +++ b/src/anvil/penalty.c @@ -121,9 +121,9 @@ static void penalty_add_checksum(struct penalty_rec *rec, unsigned int checksum) if (!rec->checksum_is_pointer) { if (rec->checksum.value[CHECKSUM_VALUE_COUNT-1] == 0) { - memcpy(rec->checksum.value + 1, rec->checksum.value, - sizeof(rec->checksum.value[0]) * - (CHECKSUM_VALUE_COUNT-1)); + memmove(rec->checksum.value + 1, rec->checksum.value, + sizeof(rec->checksum.value[0]) * + (CHECKSUM_VALUE_COUNT-1)); rec->checksum.value[0] = checksum; return; }