提交 2a4e2e49 编写于 作者: P Philippe Mathieu-Daudé 提交者: Michael Tokarev

loader: check get_image_size() return value

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: NPhilippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: NEric Blake <eblake@redhat.com>
Reviewed-by: NAlistair Francis <alistair.francis@xilinx.com>
Signed-off-by: NMichael Tokarev <mjt@tls.msk.ru>
上级 b94b330e
......@@ -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) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册