aboutsummaryrefslogtreecommitdiff
path: root/debian/patches/057_nx-X11-bigendian-ppc64-no-session-window.full.patch
blob: 901aba61d396c1b86d02f41fb31d3b6f787aa5ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
Description: No session window with on PPC64 builds
Author: Mihai Moldovan <ionic@ionic.de>
Abstract:
 Multiple endiannes issues were setting incorrect event masks when creating and
 drawing X11 windows.
 .
 This time, a smaller integer has been casted to a bigger one and passed to some
 function actually setting its value.
 .
 This meant, that garbage from stack was attached to the smaller integer value,
 putting unknown memory into the lower bytes of the bigger integer.
 .
 Fix this by creating a big, initialized temporary variable, let the function do
 its magic on that one and pass the value back to the smaller variable--and
 cross your fingers the smaller variable can hold it without overrunning. (The
 last bit is a design issue we can't really fix and has been around even before
 this patch.)

--- a/nx-X11/programs/Xserver/hw/nxagent/Window.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Window.c
@@ -327,7 +327,10 @@
 
   if (mask & CWEventMask)
   {
-    nxagentGetEventMask(pWin, (Mask*)&attributes.event_mask);
+    /* Assume that the mask fits in int... broken on Big Endian 64bit systems. */
+    Mask tmp_mask = attributes.event_mask;
+    nxagentGetEventMask(pWin, &tmp_mask);
+    attributes.event_mask = (int)tmp_mask;
   }
   #ifdef WARNING
   else
@@ -2891,7 +2894,10 @@
 
   if (mask & CWEventMask)
   {
-    nxagentGetEventMask(pWin, (Mask*)&attributes.event_mask);
+    /* Assume that the mask fits in int... broken on Big Endian 64bit systems. */
+    Mask tmp_mask = attributes.event_mask;
+    nxagentGetEventMask(pWin, &tmp_mask);
+    attributes.event_mask = (int)tmp_mask;
   }
   #ifdef WARNING
   else
@@ -3352,7 +3358,10 @@
 
   if (nxagentOption(Rootless) && nxagentWindowTopLevel(pWin))
   {
-    nxagentGetEventMask(pWin, (Mask*)&attributes.event_mask);
+    /* Assume that the mask fits in int... broken on Big Endian 64bit systems. */
+    Mask tmp_mask = attributes.event_mask;
+    nxagentGetEventMask(pWin, &tmp_mask);
+    attributes.event_mask = (int)tmp_mask;
 
     XChangeWindowAttributes(nxagentDisplay, nxagentWindow(pWin), mask, &attributes);
   }
--- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c
@@ -1665,7 +1665,10 @@
 
     attributes.background_pixel = nxagentBlackPixel;
 
-    nxagentGetDefaultEventMask((Mask*)&attributes.event_mask);
+    /* Assume that the mask fits in int... broken on Big Endian 64bit systems. */
+    Mask tmp_mask = attributes.event_mask;
+    nxagentGetDefaultEventMask(&tmp_mask);
+    attributes.event_mask = (int)tmp_mask;
 
     attributes.colormap = nxagentDefaultVisualColormap(nxagentDefaultVisual(pScreen));