Skip to contentSkip to conversation

qemu-option: Fix uninitialized value in append_option_parameter

PATCH Applied Kevin Wolf 3 participants 3 messages Jun 11, 2010 – Jun 14, 2010

lore
Share & tools
lore

Kevin Wolf

author
#0 lore raw

PATCH 1/1 qemu-option: Fix uninitialized value in append_option_parameter

When dest is NULL, i.e. a new copy of the list is created, we don't get a properly terminated list after the realloc. Initialize it as an empty list.

---

Xudong, can you please try this one? I think it should fix your qemu-img problem.

 qemu-option.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
qemu-option.c +1 -0
index acd74f9..f884865 100644
@@ -378,6 +378,7 @@ QEMUOptionParameter *append_option_parameters(QEMUOptionParameter *dest,
     num_options += count_option_parameters(list);
 
     dest = qemu_realloc(dest, (num_options + 1) * sizeof(QEMUOptionParameter));
+    dest[num_dest_options].name = NULL;
 
     while (list && list->name) {
         if (get_option_parameter(dest, list->name) == NULL) {
Signature · 1 line
1.6.6.1
#1 lore raw

Kevin, this patch works fine.

Quoted 28 lines · Kevin Wolf

When dest is NULL, i.e. a new copy of the list is created, we don't get a
properly terminated list after the realloc. Initialize it as an empty list.

---

Xudong, can you please try this one? I think it should fix your qemu-img
problem.

 qemu-option.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
qemu-option.c +1 -0
index acd74f9..f884865 100644
@@ -378,6 +378,7 @@ QEMUOptionParameter
     *append_option_parameters(QEMUOptionParameter *dest, num_options
+= count_option_parameters(list); 
 
     dest = qemu_realloc(dest, (num_options + 1) *
 sizeof(QEMUOptionParameter)); +    dest[num_dest_options].name = NULL;
 
     while (list && list->name) {
         if (get_option_parameter(dest, list->name) == NULL) {
#2 lore raw
In reply to Kevin Wolf
Quoted 5 lines · Kevin Wolf

When dest is NULL, i.e. a new copy of the list is created, we don't get a properly terminated list after the realloc. Initialize it as an empty list.

Applied. Thanks.

Regards,

Anthony Liguori

Quoted 21 lines

---

Xudong, can you please try this one? I think it should fix your qemu-img problem.

  qemu-option.c |    1 +
  1 files changed, 1 insertions(+), 0 deletions(-)
qemu-option.c +1 -0
index acd74f9..f884865 100644
@@ -378,6 +378,7 @@ QEMUOptionParameter *append_option_parameters(QEMUOptionParameter *dest,
      num_options += count_option_parameters(list);
 
      dest = qemu_realloc(dest, (num_options + 1) * sizeof(QEMUOptionParameter));
+    dest[num_dest_options].name = NULL;
 
      while (list&&  list->name) {
          if (get_option_parameter(dest, list->name) == NULL) {