]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
tpm: use memmove() for overlapping buffers
authorHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Sat, 2 Nov 2024 10:27:37 +0000 (11:27 +0100)
committerIlias Apalodimas <ilias.apalodimas@linaro.org>
Sat, 16 Nov 2024 17:21:59 +0000 (19:21 +0200)
The behavior of memcpy() for overlapping buffers is undefined.

Fixes: 4c57ec76b725 ("tpm: Implement state command for Cr50")
Addresses-Coverity-ID: 356664 Overlapping buffer in memory copy
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
lib/tpm-v2.c

index 59e6cbafafaa1f86196ea7a17226fd7861cfe7ae..ad2b5ab0c327811bd6fd5a5a2b8ad3bcc71fa322 100644 (file)
@@ -821,7 +821,7 @@ u32 tpm2_report_state(struct udevice *dev, uint vendor_cmd, uint vendor_subcmd,
        if (*recv_size < 12)
                return -ENODATA;
        *recv_size -= 12;
-       memcpy(recvbuf, recvbuf + 12, *recv_size);
+       memmove(recvbuf, recvbuf + 12, *recv_size);
 
        return 0;
 }