qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] migration: don't segfault on invalid input


From: Michael S. Tsirkin
Subject: [Qemu-devel] [PATCH] migration: don't segfault on invalid input
Date: Sun, 17 Oct 2010 20:43:40 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

host_from_stream_offset returns NULL on error,
return error instead of trying to use that address,
to avoid segfault on invalid stream.

Signed-off-by: Michael S. Tsirkin <address@hidden>
---
 arch_init.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/arch_init.c b/arch_init.c
index e468c0c..bc7528d 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -116,6 +116,8 @@ static int ram_save_block(QEMUFile *f)
 
     if (!block)
         block = QLIST_FIRST(&ram_list.blocks);
+    if (!last_block)
+       last_block = block;
 
     current_addr = block->offset + offset;
 
@@ -390,6 +392,9 @@ int ram_load(QEMUFile *f, void *opaque, int version_id)
                 host = qemu_get_ram_ptr(addr);
             else
                 host = host_from_stream_offset(f, addr, flags);
+            if (!host) {
+                return -EINVAL;
+            }
 
             ch = qemu_get_byte(f);
             memset(host, ch, TARGET_PAGE_SIZE);
-- 
1.7.3-rc1



reply via email to

[Prev in Thread] Current Thread [Next in Thread]