aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnastasia Belova <abelova@astralinux.ru>2024-01-15 12:22:16 +0300
committerPeter Maydell <peter.maydell@linaro.org>2024-01-15 17:14:22 +0000
commit7ec39730a9cc443c752d4cad2bf1c00467551ef5 (patch)
treef61a22ed7d46550ac6ce945e65c35a0cac399d7d
parent8869bdbb29882edd4fd32baf6b4aa0dd4d927368 (diff)
load_elf: fix iterator's type for elf file processingpull-target-arm-20240116
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>
-rw-r--r--include/hw/elf_ops.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/include/hw/elf_ops.h b/include/hw/elf_ops.h
index 0a5c258fe6..9c35d1b9da 100644
--- a/include/hw/elf_ops.h
+++ b/include/hw/elf_ops.h
@@ -500,7 +500,7 @@ static ssize_t glue(load_elf, SZ)(const char *name, int fd,
}
if (data_swab) {
- int j;
+ elf_word j;
for (j = 0; j < file_size; j += (1 << data_swab)) {
uint8_t *dp = data + j;
switch (data_swab) {