[Python-checkins] bpo-33164: blake2: Fix Coverity scan (GH-25060)

miss-islington webhook-mailer at python.org
Tue Mar 30 00:36:48 EDT 2021


https://github.com/python/cpython/commit/05429c917c23f735b07ac4c60af20e57aad742fc
commit: 05429c917c23f735b07ac4c60af20e57aad742fc
branch: 3.9
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2021-03-29T21:36:39-07:00
summary:

bpo-33164: blake2: Fix Coverity scan (GH-25060)

(cherry picked from commit 068ebf9729d440cef03e4c57e3db83c851146172)

Co-authored-by: Inada Naoki <songofacandy at gmail.com>

files:
M Modules/_blake2/impl/blake2b-ref.c
M Modules/_blake2/impl/blake2b.c
M Modules/_blake2/impl/blake2s-ref.c
M Modules/_blake2/impl/blake2s.c

diff --git a/Modules/_blake2/impl/blake2b-ref.c b/Modules/_blake2/impl/blake2b-ref.c
index 699f1a1da1dec..e58c43659d9cc 100644
--- a/Modules/_blake2/impl/blake2b-ref.c
+++ b/Modules/_blake2/impl/blake2b-ref.c
@@ -333,7 +333,7 @@ int blake2b_final( blake2b_state *S, uint8_t *out, size_t outlen )
     blake2b_increment_counter( S, BLAKE2B_BLOCKBYTES );
     blake2b_compress( S, S->buf );
     S->buflen -= BLAKE2B_BLOCKBYTES;
-    memcpy( S->buf, S->buf + BLAKE2B_BLOCKBYTES, S->buflen );
+    memmove( S->buf, S->buf + BLAKE2B_BLOCKBYTES, S->buflen );
   }
 
   blake2b_increment_counter( S, S->buflen );
diff --git a/Modules/_blake2/impl/blake2b.c b/Modules/_blake2/impl/blake2b.c
index 3d3e46506f2e7..c1068e8640546 100644
--- a/Modules/_blake2/impl/blake2b.c
+++ b/Modules/_blake2/impl/blake2b.c
@@ -388,7 +388,7 @@ int blake2b_final( blake2b_state *S, uint8_t *out, size_t outlen )
     blake2b_increment_counter( S, BLAKE2B_BLOCKBYTES );
     blake2b_compress( S, S->buf );
     S->buflen -= BLAKE2B_BLOCKBYTES;
-    memcpy( S->buf, S->buf + BLAKE2B_BLOCKBYTES, S->buflen );
+    memmove( S->buf, S->buf + BLAKE2B_BLOCKBYTES, S->buflen );
   }
 
   blake2b_increment_counter( S, S->buflen );
diff --git a/Modules/_blake2/impl/blake2s-ref.c b/Modules/_blake2/impl/blake2s-ref.c
index baf0b58351aef..ab86cc1b34e67 100644
--- a/Modules/_blake2/impl/blake2s-ref.c
+++ b/Modules/_blake2/impl/blake2s-ref.c
@@ -323,7 +323,7 @@ int blake2s_final( blake2s_state *S, uint8_t *out, size_t outlen )
     blake2s_increment_counter( S, BLAKE2S_BLOCKBYTES );
     blake2s_compress( S, S->buf );
     S->buflen -= BLAKE2S_BLOCKBYTES;
-    memcpy( S->buf, S->buf + BLAKE2S_BLOCKBYTES, S->buflen );
+    memmove( S->buf, S->buf + BLAKE2S_BLOCKBYTES, S->buflen );
   }
 
   blake2s_increment_counter( S, ( uint32_t )S->buflen );
diff --git a/Modules/_blake2/impl/blake2s.c b/Modules/_blake2/impl/blake2s.c
index 3a04328ab8a4f..47514685b8f30 100644
--- a/Modules/_blake2/impl/blake2s.c
+++ b/Modules/_blake2/impl/blake2s.c
@@ -363,7 +363,7 @@ int blake2s_final( blake2s_state *S, uint8_t *out, size_t outlen )
     blake2s_increment_counter( S, BLAKE2S_BLOCKBYTES );
     blake2s_compress( S, S->buf );
     S->buflen -= BLAKE2S_BLOCKBYTES;
-    memcpy( S->buf, S->buf + BLAKE2S_BLOCKBYTES, S->buflen );
+    memmove( S->buf, S->buf + BLAKE2S_BLOCKBYTES, S->buflen );
   }
 
   blake2s_increment_counter( S, ( uint32_t )S->buflen );



More information about the Python-checkins mailing list