Fix potentially undefined behaviour when computing a sha1 value.
authorNick Clifton <nickc@redhat.com>
Tue, 16 Mar 2021 14:43:17 +0000 (14:43 +0000)
committerNick Clifton <nickc@redhat.com>
Tue, 16 Mar 2021 14:43:17 +0000 (14:43 +0000)
libiberty/
* sha1.c (sha1_process_bytes): Use memmove in place of memcpy.

libiberty/sha1.c

index e3d7f86..7d15d48 100644 (file)
@@ -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;
     }