]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Fix potential overlap dest buffer
authorNigel Croxon <ncroxon@redhat.com>
Tue, 17 Aug 2021 13:14:48 +0000 (09:14 -0400)
committerJes Sorensen <jsorensen@fb.com>
Fri, 8 Oct 2021 15:49:54 +0000 (11:49 -0400)
To meet requirements of Common Criteria certification vulnerablility
assessment. Static code analysis has been run and found the following
error.  Overlapping_buffer: The source buffer potentially overlaps
with the destination buffer, which results in undefined
behavior for "memcpy".

The change is to use memmove instead of memcpy.

Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
sha1.c

diff --git a/sha1.c b/sha1.c
index 11be7045abfa42050f4ebc586574e6fb8b99df4b..89b32f469a43771cc1232de0f2d1c59c301d1191 100644 (file)
--- a/sha1.c
+++ b/sha1.c
@@ -258,7 +258,7 @@ sha1_process_bytes (const void *buffer, size_t len, struct sha1_ctx *ctx)
        {
          sha1_process_block (ctx->buffer, 64, ctx);
          left_over -= 64;
-         memcpy (ctx->buffer, &ctx->buffer[16], left_over);
+         memmove (ctx->buffer, &ctx->buffer[16], left_over);
        }
       ctx->buflen = left_over;
     }