Skip to content

Commit 01d92b5

Browse files
zzambersPaul Hohensee
authored andcommitted
8343618: Stack smashing in awt_InputMethod.c on Linux s390x
Backport-of: ee6891456ed672305d9b48846b5a7977373e1284
1 parent 6a2ed7c commit 01d92b5

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/java.desktop/unix/native/libawt_xawt/awt/awt_InputMethod.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1618,14 +1618,14 @@ JNIEXPORT jboolean JNICALL Java_sun_awt_X11InputMethodBase_setCompositionEnabled
16181618
if (NULL != pX11IMData->statusWindow) {
16191619
Window focus = 0;
16201620
int revert_to;
1621-
#if defined(_LP64) && !defined(_LITTLE_ENDIAN)
1622-
// The Window value which is used for XGetICValues must be 32bit on BigEndian XOrg's xlib
1623-
unsigned int w = 0;
1624-
#else
16251621
Window w = 0;
1626-
#endif
16271622
XGetInputFocus(awt_display, &focus, &revert_to);
16281623
XGetICValues(pX11IMData->current_ic, XNFocusWindow, &w, NULL);
1624+
#if defined(_LP64) && !defined(_LITTLE_ENDIAN)
1625+
// On 64bit BigEndian,
1626+
// Window value may be stored on high 32bit by XGetICValues via XIM
1627+
if (w > 0xffffffffUL) w = w >> 32;
1628+
#endif
16291629
if (RevertToPointerRoot == revert_to
16301630
&& pX11IMData->ic_active != pX11IMData->ic_passive) {
16311631
if (pX11IMData->current_ic == pX11IMData->ic_active) {
@@ -1674,12 +1674,7 @@ JNIEXPORT jboolean JNICALL Java_sun_awt_X11InputMethodBase_isCompositionEnabledN
16741674
{
16751675
X11InputMethodData *pX11IMData = NULL;
16761676
char * ret = NULL;
1677-
#if defined(__linux__) && defined(_LP64) && !defined(_LITTLE_ENDIAN)
1678-
// XIMPreeditState value which is used for XGetICValues must be 32bit on BigEndian XOrg's xlib
1679-
unsigned int state = XIMPreeditUnKnown;
1680-
#else
16811677
XIMPreeditState state = XIMPreeditUnKnown;
1682-
#endif
16831678

16841679
XVaNestedList pr_atrb;
16851680

@@ -1695,6 +1690,11 @@ JNIEXPORT jboolean JNICALL Java_sun_awt_X11InputMethodBase_isCompositionEnabledN
16951690
ret = XGetICValues(pX11IMData->current_ic, XNPreeditAttributes, pr_atrb, NULL);
16961691
XFree((void *)pr_atrb);
16971692
AWT_UNLOCK();
1693+
#if defined(__linux__) && defined(_LP64) && !defined(_LITTLE_ENDIAN)
1694+
// On 64bit BigEndian,
1695+
// XIMPreeditState value may be stored on high 32bit by XGetICValues via XIM
1696+
if (state > 0xffffffffUL) state = state >> 32;
1697+
#endif
16981698

16991699
if ((ret != 0)
17001700
&& ((strcmp(ret, XNPreeditAttributes) == 0)

0 commit comments

Comments
 (0)