Patchwork [PULL,2/2] migration: don't use uninitialized variables

login
register
mail settings
Submitter Luiz Capitulino
Date Aug. 1, 2013, 2:32 p.m.
Message ID <1375367564-4797-3-git-send-email-lcapitulino@redhat.com>
Download mbox | patch
Permalink /patch/264031/
State New
Headers show

Comments

Luiz Capitulino - Aug. 1, 2013, 2:32 p.m.
From: Pawit Pornkitprasan <p.pawit@gmail.com>

The qmp_migrate method uses the 'blk' and 'inc' parameter without
checking if they're valid or not (they may be uninitialized if
command is received via QMP)

Signed-off-by: Pawit Pornkitprasan <p.pawit@gmail.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 migration.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Patch

diff --git a/migration.c b/migration.c
index 3f682cd..1402fa7 100644
--- a/migration.c
+++ b/migration.c
@@ -400,8 +400,8 @@  void qmp_migrate(const char *uri, bool has_blk, bool blk,
     MigrationParams params;
     const char *p;
 
-    params.blk = blk;
-    params.shared = inc;
+    params.blk = has_blk && blk;
+    params.shared = has_inc && inc;
 
     if (s->state == MIG_STATE_ACTIVE || s->state == MIG_STATE_SETUP) {
         error_set(errp, QERR_MIGRATION_ACTIVE);