From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org, Alex Williamson <alex.williamson@redhat.com>
Subject: [Qemu-devel] [PATCH] migration: don't segfault on invalid input
Date: Sun, 17 Oct 2010 20:43:40 +0200 [thread overview]
Message-ID: <20101017184340.GA12524@redhat.com> (raw)
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 | 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
next reply other threads:[~2010-10-17 18:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-17 18:43 Michael S. Tsirkin [this message]
2010-10-17 21:01 ` [Qemu-devel] Re: [PATCH] migration: don't segfault on invalid input Alex Williamson
2010-10-17 21:10 ` Michael S. Tsirkin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20101017184340.GA12524@redhat.com \
--to=mst@redhat.com \
--cc=alex.williamson@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).