]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
anvil: Use memmove() for moving penalty checksum buffer
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 28 Feb 2022 19:43:27 +0000 (14:43 -0500)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Fri, 15 Jul 2022 07:33:24 +0000 (07:33 +0000)
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

src/anvil/penalty.c

index 3776b96f058a2b3afc724ac433db5af507c4e014..30c0a7bc175939fc0abb69ebe878f6f94e8cc361 100644 (file)
@@ -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;
                }