Skip to contentSkip to conversation

vnc_refresh: calling vnc_update_client might free vs

PATCH Applied Stefano Stabellini 3 participants 5 messages Jan 25, 2010 – Jan 27, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vnc_refresh: calling vnc_update_client might free vs

Hi all,
this patch fixes another bug in vnc_refresh: calling vnc_update_client might cause vs to be free()ed, in this case we cannot access vs->next right after to examine the next item on the list.

---

vnc.c +4 -2
index cc2a26e..92facde 100644
@@ -2345,7 +2345,7 @@ static int vnc_refresh_server_surface(VncDisplay *vd)
 static void vnc_refresh(void *opaque)
 {
     VncDisplay *vd = opaque;
-    VncState *vs = NULL;
+    VncState *vs = NULL, *vn = NULL;
     int has_dirty = 0, rects = 0;
 
     vga_hw_update();
@@ -2354,8 +2354,10 @@ static void vnc_refresh(void *opaque)
 
     vs = vd->clients;
     while (vs != NULL) {
+        vn = vs->next;
         rects += vnc_update_client(vs, has_dirty);
-        vs = vs->next;
+        /* vs might be free()ed here */
+        vs = vn;
     }
     /* vd->timer could be NULL now if the last client disconnected,
      * in this case don't update the timer */
#1 lore raw
Quoted 7 lines · Stefano Stabellini

Hi all,
this patch fixes another bug in vnc_refresh: calling vnc_update_client might cause vs to be free()ed, in this case we cannot access vs->next right after to examine the next item on the list.

Applied. Thanks.

Regards,

Anthony Liguori

Quoted 31 lines

---

vnc.c +4 -2
index cc2a26e..92facde 100644
@@ -2345,7 +2345,7 @@ static int vnc_refresh_server_surface(VncDisplay *vd)
  static void vnc_refresh(void *opaque)
  {
      VncDisplay *vd = opaque;
-    VncState *vs = NULL;
+    VncState *vs = NULL, *vn = NULL;
      int has_dirty = 0, rects = 0;
 
      vga_hw_update();
@@ -2354,8 +2354,10 @@ static void vnc_refresh(void *opaque)
 
      vs = vd->clients;
      while (vs != NULL) {
+        vn = vs->next;
          rects += vnc_update_client(vs, has_dirty);
-        vs = vs->next;
+        /* vs might be free()ed here */
+        vs = vn;
      }
      /* vd->timer could be NULL now if the last client disconnected,
       * in this case don't update the timer */
#2 lore raw
Quoted 9 lines · Anthony Liguori
Quoted 6 lines · Stefano Stabellini

Hi all,
this patch fixes another bug in vnc_refresh: calling vnc_update_client might cause vs to be free()ed, in this case we cannot access vs->next right after to examine the next item on the list.

Applied. Thanks.

IMHO this should go to stable too.

cheers,
Gerd

#3 lore raw
Quoted 7 lines · Gerd Hoffmann
Quoted 6 lines · Anthony Liguori
Quoted 5 lines · Stefano Stabellini

Hi all,
this patch fixes another bug in vnc_refresh: calling vnc_update_client might cause vs to be free()ed, in this case we cannot access vs->next right after to examine the next item on the list.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Applied. Thanks.

IMHO this should go to stable too.

Yes, good idea.

#4 lore raw
Quoted 11 lines · Stefano Stabellini
Quoted 9 lines · Gerd Hoffmann
Quoted 7 lines · Anthony Liguori
Quoted 5 lines · Stefano Stabellini

Hi all,
this patch fixes another bug in vnc_refresh: calling vnc_update_client might cause vs to be free()ed, in this case we cannot access vs->next right after to examine the next item on the list.

Quoted 9 lines
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

Applied. Thanks.

IMHO this should go to stable too.

Yes, good idea.

Already did.

Regards,

Anthony Liguori