]> git.ipfire.org Git - thirdparty/qemu.git/commit
load_elf: fix iterator's type for elf file processing
authorAnastasia Belova <abelova@astralinux.ru>
Mon, 15 Jan 2024 09:22:16 +0000 (12:22 +0300)
committerMichael Tokarev <mjt@tls.msk.ru>
Fri, 19 Jan 2024 10:41:14 +0000 (13:41 +0300)
commit2ad4ebb350fa3340488f2bb9c751726e449597e1
tree6d3307673a1383f7dd123144d8bd5cbc2f7ca6e1
parentc59ce9fef694fff56394ef4a8983c67464286ee9
load_elf: fix iterator's type for elf file processing

j is used while loading an ELF file to byteswap segments'
data. If data is larger than 2GB an overflow may happen.
So j should be elf_word.

This commit fixes a minor bug: it's unlikely anybody is trying to
load ELF files with 2GB+ segments for wrong-endianness targets,
but if they did, it wouldn't work correctly.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Cc: qemu-stable@nongnu.org
Fixes: 7ef295ea5b ("loader: Add data swap option to load-elf")
Signed-off-by: Anastasia Belova <abelova@astralinux.ru>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
(cherry picked from commit 410c2a4d75f52f6a2fe978eda5a9b6f854afe5ea)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
include/hw/elf_ops.h