]> git.proxmox.com Git - qemu.git/commitdiff
migration: don't segfault on invalid input
authorMichael S. Tsirkin <mst@redhat.com>
Sun, 17 Oct 2010 18:43:40 +0000 (20:43 +0200)
committerMichael S. Tsirkin <mst@redhat.com>
Wed, 27 Oct 2010 16:54:02 +0000 (18:54 +0200)
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 <mst@redhat.com>
arch_init.c

index a910033c8c07f2469efc13aa78c439c309153c38..4caadd0c0acee6e9383a01222e923b7e80d386c2 100644 (file)
@@ -390,6 +390,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);