Hi,
On 21/12/23 09:08, Anastasia Belova wrote:
file_size is uint32_t, so j < file_size should be
uint32_t too.
file_size is of elf_word type, which is either uint32_t
or uint64_t.
Your explanation is not very clear... Maybe you want an unsigned type?
In that case, does the following makes your sanitizer happier?
-- >8 --
diff --git a/include/hw/elf_ops.h b/include/hw/elf_ops.h
index 0a5c258fe6..03eba78c6e 100644
--- a/include/hw/elf_ops.h
+++ b/include/hw/elf_ops.h
@@ -502,4 +502,3 @@ static ssize_t glue(load_elf, SZ)(const char *name,
int fd,
if (data_swab) {
- int j;
- for (j = 0; j < file_size; j += (1 << data_swab)) {
+ for (unsigned j = 0; j < file_size; j += (1 <<
data_swab)) {
uint8_t *dp = data + j;
---
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes: 7ef295ea5b ("loader: Add data swap option to load-elf")
Signed-off-by: Anastasia Belova <abel...@astralinux.ru>
---
include/hw/elf_ops.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/hw/elf_ops.h b/include/hw/elf_ops.h
index 0a5c258fe6..1defccaa71 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;
+ uint32_t j;
for (j = 0; j < file_size; j += (1 << data_swab)) {
uint8_t *dp = data + j;
switch (data_swab) {