Dear TigerVNC developers,

I am working for a company, that builds a Linux OS, and I had to integrate the VNC module loadable by the X-Server.

While doing this for X-Server 1.10.1, I found out that there are some problems related to data padding in the extension communication (see unix_xserver_hw_vnc_vncExtInit_cc_QUERYCONNECT.patch).

Besides this, I had some crashes of the X-Server, which can be avoided by checking the limit (see unix_xserver_hw_vnc_XserverDesktop_cc_LIMIT.patch)

Beyond that, I had the requirement for patches related to the RandR 1.2 interface (see unix_xserver_hw_vnc_vncHooks_cc_RANDR.patch).

And finally, I need some additional RandR based patches (see common_rfb_SDesktop_h_VIRTUAL.patch, common_rfb_VNCSConnectionST_cxx_VIRTUAL.patch, unix_xserver_hw_vnc_XserverDesktop_cc_VIRTUAL.patch, unix_xserver_hw_vnc_XserverDesktop_h_VIRTUAL.patch).

All patches are attached, even if they correspond not to the newest version of the code. Sorry for that.

Maybe these patches can be checked and the official code modified.

Best regards,
Christian

--

Dr. Christian Steinle 
System Architect Linux OS 

Unicon Software GmbH 
Philipp-Reis-Str. 1 
76137 Karlsruhe 
Germany 
Tel. +49 (0)721 96451-0 
Fax +49 (0)721 96451-43 
Email: christian.stei...@unicon-software.com
Web: www.unicon-software.com 

This communication contains information that is confidential, proprietary in nature and/or privileged. It is for the exclusive use of the intended recipient(s). If you are not the intended recipient(s) or the person responsible for delivering it to the intended recipient(s), please note that any form of dissemination, distribution or copying of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender and delete the original communication. Thank you for your cooperation.

--- common/rfb/SDesktop.h.orig
+++ common/rfb/SDesktop.h
@@ -83,6 +83,14 @@
       return resultProhibited;
     }
 
+    // validateFramebufferSize() requests to check for correct sizes
+    // Necessary for graphics drivers, which need a Virtual statement
+    // in the xorg.conf to allow modifications via RandR, because
+    // otherwise the VNC size corresponds initially to the Virtual
+    // and not to the correct screen sizes
+    // Function is implemented effectively in the class XserverDesktop
+    virtual void validateFramebufferSize(int width = 0, int height = 0) {}
+
     // InputHandler interface
     // pointerEvent(), keyEvent() and clientCutText() are called in response to
     // the relevant RFB protocol messages from clients.



--- common/rfb/VNCSConnectionST.cxx.orig
+++ common/rfb/VNCSConnectionST.cxx
@@ -345,6 +345,8 @@
 {
   lastEventTime = time(0);
 
+  server->desktop->validateFramebufferSize(server->pb->width(), 
server->pb->height());
+
   server->startDesktop();
 
   // - Set the connection parameters appropriately



--- unix/xserver/hw/vnc/vncExtInit.cc.orig
+++ unix/xserver/hw/vnc/vncExtInit.cc
@@ -843,13 +843,14 @@
   rep.addrLen = qcTimeout ? strlen(qcAddress) : 0;
   rep.userLen = qcTimeout ? strlen(qcUsername) : 0;
   rep.opaqueId = (CARD32)(long)queryConnectId;
-  rep.length = (rep.userLen + rep.addrLen + 3) >> 2;
+  rep.length = ((rep.addrLen + 3) >> 2) + ((rep.userLen + 3) >> 2);
   if (client->swapped) {
     swaps(&rep.sequenceNumber, n);
-    swapl(&rep.userLen, n);
     swapl(&rep.addrLen, n);
+    swapl(&rep.userLen, n);
     swapl(&rep.timeout, n);
     swapl(&rep.opaqueId, n);
+    swapl(&rep.length, n);
   }
   WriteToClient(client, sizeof(xVncExtGetQueryConnectReply), (char *)&rep);
   if (qcTimeout)



--- unix/xserver/hw/vnc/vncHooks.cc.orig
+++ unix/xserver/hw/vnc/vncHooks.cc
@@ -83,8 +83,13 @@
   CompositeProcPtr             Composite;
 #endif
 #ifdef RANDR
+#if RANDR_12_INTERFACE
+  RRCrtcSetProcPtr             RandRCrtcSet;
+#endif
+#if RANDR_10_INTERFACE
   RRSetConfigProcPtr           RandRSetConfig;
 #endif
+#endif
 } vncHooksScreenRec, *vncHooksScreenPtr;
 
 typedef struct {
@@ -141,9 +146,17 @@
                              INT16 yMask, INT16 xDst, INT16 yDst, CARD16 
width, CARD16 height);
 #endif
 #ifdef RANDR
+#if RANDR_12_INTERFACE
+static Bool vncHooksRandRCrtcSet(ScreenPtr pScreen, RRCrtcPtr randr_crtc,
+                                 RRModePtr randr_mode, int x, int y,
+                                 Rotation rotation, int num_randr_outputs,
+                                 RROutputPtr *randr_outputs);
+#endif
+#if RANDR_10_INTERFACE
 static Bool vncHooksRandRSetConfig(ScreenPtr pScreen, Rotation rotation,
                                    int rate, RRScreenSizePtr pSize);
 #endif
+#endif
 
 // GC "funcs"
 
@@ -282,7 +295,16 @@
   rrScrPrivPtr rp;
   rp = rrGetScrPriv(pScreen);
   if (rp) {
+#if RANDR_12_INTERFACE
+    vncHooksScreen->RandRCrtcSet = rp->rrCrtcSet;
+    if (vncHooksScreen->RandRCrtcSet != NULL)
+      rp->rrCrtcSet = vncHooksRandRCrtcSet;
+#endif
+#if RANDR_10_INTERFACE
     vncHooksScreen->RandRSetConfig = rp->rrSetConfig;
+    if (vncHooksScreen->RandRSetConfig != NULL)
+      rp->rrSetConfig = vncHooksRandRSetConfig;
+#endif
   }
 #endif
 
@@ -302,11 +324,6 @@
     ps->Composite = vncHooksComposite;
   }
 #endif
-#ifdef RANDR
-  if (rp) {
-    rp->rrSetConfig = vncHooksRandRSetConfig;
-  }
-#endif
 
   return TRUE;
 }
@@ -360,7 +377,12 @@
   rrScrPrivPtr rp;
   rp = rrGetScrPriv(pScreen);
   if (rp) {
+#if RANDR_12_INTERFACE
+    rp->rrCrtcSet = vncHooksScreen->RandRCrtcSet;
+#endif
+#if RANDR_10_INTERFACE
     rp->rrSetConfig = vncHooksScreen->RandRSetConfig;
+#endif
   }
 #endif
 
@@ -596,6 +618,50 @@
 
 #ifdef RANDR
 
+#if RANDR_12_INTERFACE
+static Bool vncHooksRandRCrtcSet(ScreenPtr pScreen, RRCrtcPtr randr_crtc,
+                                 RRModePtr randr_mode, int x, int y,
+                                 Rotation rotation, int num_randr_outputs,
+                                 RROutputPtr *randr_outputs)
+{
+  vncHooksScreenPtr vncHooksScreen = vncHooksScreenPrivate(pScreen);
+  rrScrPrivPtr rp = rrGetScrPriv(pScreen);
+  Bool ret;
+  RegionRec reg;
+  BoxRec box;
+
+  if (vncHooksScreen->RandRCrtcSet != NULL) {
+
+    rp->rrCrtcSet = vncHooksScreen->RandRCrtcSet;
+    ret = (*rp->rrCrtcSet)(pScreen, randr_crtc, randr_mode, x, y, rotation, 
num_randr_outputs, randr_outputs);
+    rp->rrCrtcSet = vncHooksRandRCrtcSet;
+
+  }
+  else
+    ret = FALSE;
+
+  if (!ret)
+    return FALSE;
+ 
+  // Let the RFB core know of the new dimensions and framebuffer
+  vncHooksScreen->desktop->setFramebuffer(pScreen->width, pScreen->height,
+                                          vncFbptr[pScreen->myNum],
+                                          vncFbstride[pScreen->myNum]);
+
+  // Mark entire screen as changed
+  box.x1 = 0;
+  box.y1 = 0;
+  box.x2 = pScreen->width;
+  box.y2 = pScreen->height;
+  REGION_INIT(pScreen, &reg, &box, 1);
+
+  vncHooksScreen->desktop->add_changed(&reg);
+
+  return TRUE;
+}
+#endif
+
+#if RANDR_10_INTERFACE
 static Bool vncHooksRandRSetConfig(ScreenPtr pScreen, Rotation rotation,
                                    int rate, RRScreenSizePtr pSize)
 {
@@ -605,9 +671,15 @@
   RegionRec reg;
   BoxRec box;
 
-  rp->rrSetConfig = vncHooksScreen->RandRSetConfig;
-  ret = (*rp->rrSetConfig)(pScreen, rotation, rate, pSize);
-  rp->rrSetConfig = vncHooksRandRSetConfig;
+  if (vncHooksScreen->RandRSetConfig) {
+
+    rp->rrSetConfig = vncHooksScreen->RandRSetConfig;
+    ret = (*rp->rrSetConfig)(pScreen, rotation, rate, pSize);
+    rp->rrSetConfig = vncHooksRandRSetConfig;
+
+  }
+  else
+    ret = FALSE;
 
   if (!ret)
     return FALSE;
@@ -635,6 +707,7 @@
 
   return TRUE;
 }
+#endif
 
 #endif /* RANDR */
 



--- unix/xserver/hw/vnc/XserverDesktop.cc.orig
+++ unix/xserver/hw/vnc/XserverDesktop.cc
@@ -758,8 +758,10 @@
 
   grabbing = true;
 
-  int bytesPerPixel = format.bpp/8;
-  int bytesPerRow = pScreen->width * bytesPerPixel;
+  unsigned int bytesPerPixel     = (unsigned int)(format.bpp/8);
+  unsigned int bytesPerRow       = (unsigned int)pScreen->width * 
bytesPerPixel;
+  unsigned int segmentationLimit = (unsigned int)pScreen->height * bytesPerRow;
+  unsigned int actualDataOffset  = 0;
 
   std::vector<rfb::Rect> rects;
   std::vector<rfb::Rect>::iterator i;
@@ -773,10 +775,12 @@
       pDrawable = (DrawablePtr) pScreen->root;
 #endif
 
-      (*pScreen->GetImage) (pDrawable, i->tl.x, y, i->width(), 1,
-                            ZPixmap, (unsigned long)~0L,
-                            ((char*)data
-                             + y * bytesPerRow + i->tl.x * bytesPerPixel));
+      /* Carefully check the segmentation, because an error will lead to an 
X-Server crash*/
+      actualDataOffset = (unsigned int)y * bytesPerRow + (unsigned int)i->tl.x 
* bytesPerPixel;
+      if (actualDataOffset < segmentationLimit)
+        (*pScreen->GetImage) (pDrawable, i->tl.x, y, i->width(), 1,
+                              ZPixmap, (unsigned long)~0L,
+                              ((char*)data + actualDataOffset));
     }
   }
   grabbing = false;



--- unix/xserver/hw/vnc/XserverDesktop.cc.orig
+++ unix/xserver/hw/vnc/XserverDesktop.cc
@@ -748,6 +748,13 @@
 }
 #endif // RANDR
 
+void XserverDesktop::validateFramebufferSize(int width, int height) {
+
+  if ((width != pScreen->width) || (height != pScreen->height))
+    setFramebuffer(pScreen->width, pScreen->height, vncFbptr[pScreen->myNum], 
vncFbstride[pScreen->myNum]);
+
+}
+
 void XserverDesktop::grabRegion(const rfb::Region& region)
 {
   if (directFbptr) return;



--- unix/xserver/hw/vnc/XserverDesktop.h.orig
+++ unix/xserver/hw/vnc/XserverDesktop.h
@@ -100,6 +100,7 @@
   virtual unsigned int setScreenLayout(int fb_width, int fb_height,
                                        const rfb::ScreenSet& layout);
 #endif
+  void validateFramebufferSize(int width = 0, int height = 0);
 
   // rfb::PixelBuffer callbacks
   virtual void grabRegion(const rfb::Region& r);



------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire 
the most talented Cisco Certified professionals. Visit the 
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html
_______________________________________________
Tigervnc-devel mailing list
Tigervnc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tigervnc-devel

Reply via email to