Tk Source Code

View Ticket
Login
Ticket UUID: 3e4c64c8b198a99d815bdcd4255d22fe55c19259
Title: crash for untrusted X connections (for ssh: ForwardX11Trusted no)
Type: Bug Version: 8.5
Submitter: anonymous Created on: 2014-01-05 07:30:23
Subsystem: 71. Error Handling Assigned To: nobody
Priority: 5 Medium Severity: Important
Status: Closed Last Modified: 2014-01-06 13:53:17
Resolution: Duplicate Closed By: dkf
    Closed on: 2014-01-06 13:53:17
Description:
Changing the InterpRegistry atom on the root window is not allowed for untrusted clients. One way to work around this might be to install xlib error handler which ignores these errors. This fixes the problem for me.

In unix/tkUnixEvent.c


 *----------------------------------------------------------------------
 *
 * XlibErrorHandler --
 *
 *      This function is called for non-fatal X errors. 
 *
 * Results:
 *      None.
 *
 * Side effects:
 *      Calls default error handler for most errors.
 *
 *----------------------------------------------------------------------
 */

static XErrorHandler OldXlibErrorHandler = NULL;
static int XlibErrorHandler(Display *d, XErrorEvent *e)
{
        /* Don't fail for BadAccess errors caused by XChangeProperty.
         * Changing the "InterpRegistry" atom on the root window fails 
         * for untrusted connections. */

        // X_ChangePropery = 18
        if ((BadAccess == e->error_code) && (18 == e->request_code))
                return 0;


        if (NULL != OldXlibErrorHandler)
                OldXlibErrorHandler(d, e);

        return 0;
}


And just install it before opening the display:

TkDisplay *
TkpOpenDisplay(
    CONST char *displayNameStr)
{
    TkDisplay *dispPtr;

    OldXlibErrorHandler = XSetErrorHandler(XlibErrorHandler);

    Display *display = XOpenDisplay(displayNameStr);

....
User Comments: dkf added on 2014-01-06 13:53:17:

dupe