diff mbox

[23/23] savevm: fix potential segfault on invalid state

Message ID 1386087086-3691-24-git-send-email-mst@redhat.com
State New
Headers show

Commit Message

Michael S. Tsirkin Dec. 3, 2013, 4:29 p.m. UTC
savevm will segfault if version_id < vmsd->minimum_version_id &&
version_id >= vmsd->minimum_version_id_old

This calls through a NULL pointer.  This is a bug (should
exit not crash).

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 savevm.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Andreas Färber March 6, 2014, 6:24 p.m. UTC | #1
Am 03.12.2013 17:29, schrieb Michael S. Tsirkin:
> savevm will segfault if version_id < vmsd->minimum_version_id &&
> version_id >= vmsd->minimum_version_id_old
> 
> This calls through a NULL pointer.  This is a bug (should
> exit not crash).
> 
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

Reviewed-by: Andreas Färber <afaerber@suse.de>

Andreas
diff mbox

Patch

diff --git a/savevm.c b/savevm.c
index 3f912dd..04349f6 100644
--- a/savevm.c
+++ b/savevm.c
@@ -1686,6 +1686,9 @@  int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd,
         return -EINVAL;
     }
     if  (version_id < vmsd->minimum_version_id) {
+        if (!vmsd->load_state_old) {
+            return -EINVAL;
+        }
         return vmsd->load_state_old(f, opaque, version_id);
     }
     if (vmsd->pre_load) {