Skip to contentSkip to conversation

vnc: fix segfault

PATCH In review Gerd Hoffmann 2 participants 3 messages Nov 25, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vnc: fix segfault

Commit "c7628bf vnc: only alloc server surface with clients connected" missed one rarely used codepath (cirrus with guest drivers using 2d accel) where we have to check for the server surface being present, to avoid qemu crashing with a NULL pointer dereference. Add the check.

---
 ui/vnc.c | 5 +++++
 1 file changed, 5 insertions(+)
ui/vnc.c +5 -0
index c9f2fed..7538405 100644
@@ -931,6 +931,11 @@ static void vnc_dpy_copy(DisplayChangeListener *dcl,
     int i, x, y, pitch, inc, w_lim, s;
     int cmp_bytes;
 
+    if (!vd->server) {
+        /* no client connected */
+        return;
+    }
+
     vnc_refresh_server_surface(vd);
     QTAILQ_FOREACH_SAFE(vs, &vd->clients, next, vn) {
         if (vnc_has_feature(vs, VNC_FEATURE_COPYRECT)) {
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 7 lines · Gerd Hoffmann

Commit "c7628bf vnc: only alloc server surface with clients connected" missed one rarely used codepath (cirrus with guest drivers using 2d accel) where we have to check for the server surface being present, to avoid qemu crashing with a NULL pointer dereference. Add the check.

This works for me.

Thanks.

Quoted 23 lines
---
 ui/vnc.c | 5 +++++
 1 file changed, 5 insertions(+)
ui/vnc.c +5 -0
index c9f2fed..7538405 100644
@@ -931,6 +931,11 @@ static void vnc_dpy_copy(DisplayChangeListener *dcl,
     int i, x, y, pitch, inc, w_lim, s;
     int cmp_bytes;
 
+    if (!vd->server) {
+        /* no client connected */
+        return;
+    }
+
     vnc_refresh_server_surface(vd);
     QTAILQ_FOREACH_SAFE(vs, &vd->clients, next, vn) {
         if (vnc_has_feature(vs, VNC_FEATURE_COPYRECT)) {
Signature · 1 line
1.8.3.1
Signature · 1 line
Anthony PERARD
#2 lore raw
In reply to Gerd Hoffmann
Quoted 7 lines · Gerd Hoffmann

Commit "c7628bf vnc: only alloc server surface with clients connected" missed one rarely used codepath (cirrus with guest drivers using 2d accel) where we have to check for the server surface being present, to avoid qemu crashing with a NULL pointer dereference. Add the check.

This works for me.

Thanks.

Quoted 23 lines
---
 ui/vnc.c | 5 +++++
 1 file changed, 5 insertions(+)
ui/vnc.c +5 -0
index c9f2fed..7538405 100644
@@ -931,6 +931,11 @@ static void vnc_dpy_copy(DisplayChangeListener *dcl,
     int i, x, y, pitch, inc, w_lim, s;
     int cmp_bytes;
 
+    if (!vd->server) {
+        /* no client connected */
+        return;
+    }
+
     vnc_refresh_server_surface(vd);
     QTAILQ_FOREACH_SAFE(vs, &vd->clients, next, vn) {
         if (vnc_has_feature(vs, VNC_FEATURE_COPYRECT)) {
Signature · 1 line
1.8.3.1
Signature · 1 line
Anthony PERARD