2010-08-26 11:09:27 +02:00
|
|
|
--- xorg-server-1.9.0/dix/window.c.orig 2010-08-23 16:07:24.000000000 +0200
|
|
|
|
+++ xorg-server-1.9.0/dix/window.c 2010-08-23 16:14:09.000000000 +0200
|
|
|
|
@@ -535,6 +535,48 @@ RealChildHead(WindowPtr pWin)
|
|
|
|
return NullWindow;
|
2010-08-23 15:32:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
+static int
|
|
|
|
+TreeDepth(WindowPtr pWin)
|
|
|
|
+{
|
|
|
|
+ int depth = 1;
|
|
|
|
+ int max_depth = 1;
|
|
|
|
+ WindowPtr pChild;
|
|
|
|
+
|
|
|
|
+ if (!(pChild = pWin))
|
2010-08-26 11:09:27 +02:00
|
|
|
+ return 0;
|
2010-08-23 15:32:09 +02:00
|
|
|
+ while (1)
|
|
|
|
+ {
|
2010-08-26 11:09:27 +02:00
|
|
|
+ if (pChild->firstChild)
|
|
|
|
+ {
|
|
|
|
+ ++depth;
|
|
|
|
+ pChild = pChild->firstChild;
|
|
|
|
+ continue;
|
|
|
|
+ } else if (depth > max_depth)
|
|
|
|
+ max_depth = depth;
|
|
|
|
+ while (!pChild->nextSib && (pChild != pWin)) {
|
|
|
|
+ --depth;
|
|
|
|
+ pChild = pChild->parent;
|
|
|
|
+ }
|
|
|
|
+ if (pChild == pWin)
|
|
|
|
+ break;
|
|
|
|
+ pChild = pChild->nextSib;
|
2010-08-23 15:32:09 +02:00
|
|
|
+ }
|
|
|
|
+ return max_depth;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static int
|
|
|
|
+WindowDepth(WindowPtr pWin)
|
|
|
|
+{
|
|
|
|
+ int depth = 0;
|
|
|
|
+ while (pWin) {
|
2010-08-26 11:09:27 +02:00
|
|
|
+ ++depth;
|
|
|
|
+ pWin = pWin->parent;
|
2010-08-23 15:32:09 +02:00
|
|
|
+ }
|
|
|
|
+ return depth;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+#define MAX_TREE_DEPTH 256
|
|
|
|
+
|
|
|
|
/*****
|
|
|
|
* CreateWindow
|
|
|
|
* Makes a window in response to client request
|
2010-08-26 11:09:27 +02:00
|
|
|
@@ -555,6 +597,11 @@ CreateWindow(Window wid, WindowPtr pPare
|
2010-08-23 15:32:09 +02:00
|
|
|
PixmapFormatRec *format;
|
|
|
|
WindowOptPtr ancwopt;
|
|
|
|
|
|
|
|
+ if (WindowDepth(pParent) >= MAX_TREE_DEPTH - 1) {
|
|
|
|
+ *error = BadAlloc;
|
|
|
|
+ return NullWindow;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
if (class == CopyFromParent)
|
|
|
|
class = pParent->drawable.class;
|
|
|
|
|
2010-08-26 11:09:27 +02:00
|
|
|
@@ -2434,6 +2481,9 @@ ReparentWindow(WindowPtr pWin, WindowPtr
|
2010-08-23 15:32:09 +02:00
|
|
|
int bw = wBorderWidth (pWin);
|
|
|
|
ScreenPtr pScreen;
|
|
|
|
|
|
|
|
+ if (WindowDepth(pParent) + TreeDepth(pWin) >= MAX_TREE_DEPTH)
|
2010-08-26 11:09:27 +02:00
|
|
|
+ return BadAlloc;
|
2010-08-23 15:32:09 +02:00
|
|
|
+
|
|
|
|
pScreen = pWin->drawable.pScreen;
|
|
|
|
if (TraverseTree(pWin, CompareWIDs, (pointer)&pParent->drawable.id) == WT_STOPWALKING)
|
2010-08-26 11:09:27 +02:00
|
|
|
return BadMatch;
|