From: Yang Shen shenyang39@huawei.com
Fix the possible memcpy overwrite.
Signed-off-by: Yang Shen shenyang39@huawei.com --- drv/isa_ce_sm4.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drv/isa_ce_sm4.c b/drv/isa_ce_sm4.c index 26bad7a..af0afd6 100644 --- a/drv/isa_ce_sm4.c +++ b/drv/isa_ce_sm4.c @@ -150,9 +150,9 @@ static void sm4_cts_cs1_mode_adapt(__u8 *cts_in, __u8 *cts_out, __u8 blocks[SM4_BLOCK_SIZE] = {0};
if (enc == SM4_ENCRYPT) { - memcpy(blocks, cts_out + SM4_BLOCK_SIZE, rsv_bytes); - memcpy(cts_out + rsv_bytes, cts_out, SM4_BLOCK_SIZE); - memcpy(cts_out, blocks, rsv_bytes); + memcpy(blocks, cts_out, SM4_BLOCK_SIZE); + memcpy(cts_out, cts_out + SM4_BLOCK_SIZE, rsv_bytes); + memcpy(cts_out + rsv_bytes, blocks, SM4_BLOCK_SIZE); } else { memcpy(blocks, cts_in + rsv_bytes, SM4_BLOCK_SIZE); memcpy(cts_in + SM4_BLOCK_SIZE, cts_in, rsv_bytes);