Skip to content

Commit 958ea4e

Browse files
ardbiesheuvelherbertx
authored andcommitted
crypto: xts - Replace memcpy() invocation with simple assignment
Colin reports that the memcpy() call in xts_cts_final() trigggers a "Overlapping buffer in memory copy" warning in Coverity, which is a false postive, given that tail is guaranteed to be smaller than or equal to the distance between source and destination. However, given that any additional bytes that we copy will be ignored anyway, we can simply copy XTS_BLOCK_SIZE unconditionally, which means we can use struct assignment of the array members instead, which is likely to be more efficient as well. Addresses-Coverity: ("Overlapping buffer in memory copy") Fixes: 8083b1b ("crypto: xts - add support for ciphertext stealing") Reported-by: Colin Ian King <[email protected]> Signed-off-by: Ard Biesheuvel <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 28ee8b0 commit 958ea4e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

crypto/xts.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ static int xts_cts_final(struct skcipher_request *req,
171171
offset - XTS_BLOCK_SIZE);
172172

173173
scatterwalk_map_and_copy(b, rctx->tail, 0, XTS_BLOCK_SIZE, 0);
174-
memcpy(b + 1, b, tail);
174+
b[1] = b[0];
175175
scatterwalk_map_and_copy(b, req->src, offset, tail, 0);
176176

177177
le128_xor(b, &rctx->t, b);

0 commit comments

Comments
 (0)