Skip to contentSkip to conversation

migration: don't use uninitialized variables

PATCH Applied Pawit Pornkitprasan 3 participants 3 messages Jul 29, 2013 – Jul 30, 2013

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 migration: don't use uninitialized variables

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)

---
 migration.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
migration.c +2 -2
index 9fc7294..57a7998 100644
@@ -399,8 +399,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);
Signature · 1 line
1.7.3.4
Reviewed-by on v2 1/1
#1 lore raw
Quoted 8 lines · Pawit Pornkitprasan

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)

---
 migration.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
Quoted 17 lines
migration.c +2 -2
index 9fc7294..57a7998 100644
@@ -399,8 +399,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);
Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#2 lore raw
In reply to Pawit Pornkitprasan
Quoted 5 lines · On Tue, 30 Jul 2013 08:39:52 +0900 Pawit Pornkitprasan <[email protected]>…

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)

Applied to the qmp branch, thanks.

Quoted 19 lines
---
 migration.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
migration.c +2 -2
index 9fc7294..57a7998 100644
@@ -399,8 +399,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);