yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
218e99
From e53520a7e7f2cf2f78786c6c1ae906e70c26fd7e Mon Sep 17 00:00:00 2001
218e99
From: Markus Armbruster <armbru@redhat.com>
218e99
Date: Tue, 6 Aug 2013 13:17:00 +0200
218e99
Subject: [PATCH 07/28] qemu-option: Fix qemu_opts_find() for null id arguments
218e99
218e99
RH-Author: Markus Armbruster <armbru@redhat.com>
218e99
Message-id: <1375795025-28674-2-git-send-email-armbru@redhat.com>
218e99
Patchwork-id: 52992
218e99
O-Subject: [PATCH 7.0 qemu-kvm 1/6] qemu-option: Fix qemu_opts_find() for null id arguments
218e99
Bugzilla: 980782
218e99
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
218e99
RH-Acked-by: Michal Novotny <minovotn@redhat.com>
218e99
RH-Acked-by: Orit Wasserman <owasserm@redhat.com>
218e99
218e99
Crashes when the first list member has an ID.  Admittedly nonsensical
218e99
reproducer:
218e99
218e99
$ qemu-system-x86_64 -nodefaults -machine id=foo -machine ""
218e99
218e99
Signed-off-by: Markus Armbruster <armbru@redhat.com>
218e99
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
218e99
Message-id: 1372943363-24081-2-git-send-email-armbru@redhat.com
218e99
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
218e99
(cherry picked from commit 96bc97ebf350ec480b69082819cedb8850f46a0f)
218e99
---
218e99
 util/qemu-option.c | 12 ++++--------
218e99
 1 file changed, 4 insertions(+), 8 deletions(-)
218e99
218e99
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
218e99
---
218e99
 util/qemu-option.c |   12 ++++--------
218e99
 1 files changed, 4 insertions(+), 8 deletions(-)
218e99
218e99
diff --git a/util/qemu-option.c b/util/qemu-option.c
218e99
index 8b74bf1..b6d2ac0 100644
218e99
--- a/util/qemu-option.c
218e99
+++ b/util/qemu-option.c
218e99
@@ -736,16 +736,12 @@ QemuOpts *qemu_opts_find(QemuOptsList *list, const char *id)
218e99
     QemuOpts *opts;
218e99
 
218e99
     QTAILQ_FOREACH(opts, &list->head, next) {
218e99
-        if (!opts->id) {
218e99
-            if (!id) {
218e99
-                return opts;
218e99
-            }
218e99
-            continue;
218e99
+        if (!opts->id && !id) {
218e99
+            return opts;
218e99
         }
218e99
-        if (strcmp(opts->id, id) != 0) {
218e99
-            continue;
218e99
+        if (opts->id && id && !strcmp(opts->id, id)) {
218e99
+            return opts;
218e99
         }
218e99
-        return opts;
218e99
     }
218e99
     return NULL;
218e99
 }
218e99
-- 
218e99
1.7.1
218e99