[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-trivial] [PATCH for 2.10 v2 02/20] loader: check get_image_size()
From: |
Philippe Mathieu-Daudé |
Subject: |
[Qemu-trivial] [PATCH for 2.10 v2 02/20] loader: check get_image_size() return value |
Date: |
Wed, 26 Jul 2017 23:42:07 -0300 |
since a negative value means it errored.
hw/core/loader.c:149:9: warning: Loss of sign in implicit conversion
if (size > max_sz) {
^~~~
hw/core/loader.c:171:9: warning: Loss of sign in implicit conversion
if (size > memory_region_size(mr)) {
^~~~
Reported-by: Clang Static Analyzer
Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Reviewed-by: Alistair Francis <address@hidden>
---
hw/core/loader.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/hw/core/loader.c b/hw/core/loader.c
index c17ace0a2e..4bb176f284 100644
--- a/hw/core/loader.c
+++ b/hw/core/loader.c
@@ -146,7 +146,7 @@ int load_image_targphys_as(const char *filename,
int size;
size = get_image_size(filename);
- if (size > max_sz) {
+ if (size < 0 || size > max_sz) {
return -1;
}
if (size > 0) {
@@ -168,7 +168,7 @@ int load_image_mr(const char *filename, MemoryRegion *mr)
size = get_image_size(filename);
- if (size > memory_region_size(mr)) {
+ if (size < 0 || size > memory_region_size(mr)) {
return -1;
}
if (size > 0) {
--
2.13.3
- [Qemu-trivial] [PATCH for 2.10 v2 00/20] fix bugs reported by Clang Static Analyzer, Philippe Mathieu-Daudé, 2017/07/26
- [Qemu-trivial] [PATCH for 2.10 v2 01/20] tests: add missing dependency to build QTEST_QEMU_BINARY, Philippe Mathieu-Daudé, 2017/07/26
- [Qemu-trivial] [PATCH for 2.10 v2 02/20] loader: check get_image_size() return value,
Philippe Mathieu-Daudé <=
- [Qemu-trivial] [PATCH for 2.10 v2 03/20] ivshmem: fix incorrect error handling in ivshmem_recv_msg(), Philippe Mathieu-Daudé, 2017/07/26
- [Qemu-trivial] [PATCH for 2.10 v2 05/20] qcow2: fix null pointer dereference, Philippe Mathieu-Daudé, 2017/07/26
- [Qemu-trivial] [PATCH for 2.10 v2 04/20] nbd: fix memory leak in nbd_opt_go(), Philippe Mathieu-Daudé, 2017/07/26
- [Qemu-trivial] [PATCH for 2.10 v2 06/20] ui/vnc: fix leak of SocketAddress **, Philippe Mathieu-Daudé, 2017/07/26
- [Qemu-trivial] [PATCH for 2.10 v2 08/20] vfio/platform: fix use of freed memory, Philippe Mathieu-Daudé, 2017/07/26
- [Qemu-trivial] [PATCH for 2.10 v2 07/20] net/eth: fix incorrect check of iov_to_buf() return value, Philippe Mathieu-Daudé, 2017/07/26
- [Qemu-trivial] [PATCH for 2.10 v2 09/20] vfio/pci: fix use of freed memory, Philippe Mathieu-Daudé, 2017/07/26
- [Qemu-trivial] [PATCH for 2.10 v2 10/20] m68k/translate: fix incorrect copy/paste, Philippe Mathieu-Daudé, 2017/07/26