Commit 2d68caca authored by Mihai Moldovan's avatar Mihai Moldovan Committed by Mike Gabriel

Create Windows and fix drawing issues on Big Endian 64bit systems…

Create Windows and fix drawing issues on Big Endian 64bit systems (057_nx-X11_sanitize-eventmasks.full.patch). 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.)
parent 4dac57f3
Description: Create Windows and fix drawing issues on Big Endian 64bit systems
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));
057_nx-X11_sanitize-eventmasks.full.patch
101_nxagent_set-rgb-path.full.patch 101_nxagent_set-rgb-path.full.patch
102_xserver-xext_set-securitypolicy-path.full.patch 102_xserver-xext_set-securitypolicy-path.full.patch
103_nxagent_set-X0-config-path.full.patch 103_nxagent_set-X0-config-path.full.patch
......
...@@ -1665,7 +1665,10 @@ N/A ...@@ -1665,7 +1665,10 @@ N/A
attributes.background_pixel = nxagentBlackPixel; 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)); attributes.colormap = nxagentDefaultVisualColormap(nxagentDefaultVisual(pScreen));
......
...@@ -327,7 +327,10 @@ FIXME: We need to set save under on the real display? ...@@ -327,7 +327,10 @@ FIXME: We need to set save under on the real display?
if (mask & CWEventMask) 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 #ifdef WARNING
else else
...@@ -2891,7 +2894,10 @@ FIXME: Do we need to set save unders attribute here? ...@@ -2891,7 +2894,10 @@ FIXME: Do we need to set save unders attribute here?
if (mask & CWEventMask) 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 #ifdef WARNING
else else
...@@ -3352,7 +3358,10 @@ void nxagentSetTopLevelEventMask(pWin) ...@@ -3352,7 +3358,10 @@ void nxagentSetTopLevelEventMask(pWin)
if (nxagentOption(Rootless) && nxagentWindowTopLevel(pWin)) 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); XChangeWindowAttributes(nxagentDisplay, nxagentWindow(pWin), mask, &attributes);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment