From f326c8fde73c2f202d7f2d39ee575fbb950bbf90bae769aaa4ce723af8f42c85 Mon Sep 17 00:00:00 2001 From: Michal Srb Date: Fri, 5 Jan 2018 11:15:21 +0000 Subject: [PATCH] Accepting request 561848 from home:michalsrb:branches:bnc1073996:X11:XOrg - n_If-auth-with-credentials-for-hostname-fails-retry-with-XAUTHLOCALHOSTNAME.patch * Prevent infinite loop also in case DISPLAY is non-local. - Use spaces instead of tabs in the patches (as does the original source code) to avoid confusion. - n_If-auth-with-credentials-for-hostname-fails-retry-with-XAUTHLOCALHOSTNAME.patch * If authentication (with *stage == 0) failed and the variable XAUTHLOCALHOSTNAME wasn't set, we were never getting to stage 2 in the original patch, causing calls to xcb_connect_to_display to be stuck in an infinite loop. Now we also go to stage 2 if the variable isn't set. OBS-URL: https://build.opensuse.org/request/show/561848 OBS-URL: https://build.opensuse.org/package/show/X11:XOrg/libxcb?expand=0&rev=47 --- bug-262309_xcb-xauthlocalhostname.diff | 25 +++++----- libxcb.changes | 18 +++++++ libxcb.spec | 2 +- ...-fails-retry-with-XAUTHLOCALHOSTNAME.patch | 47 ++++++++++--------- 4 files changed, 56 insertions(+), 36 deletions(-) diff --git a/bug-262309_xcb-xauthlocalhostname.diff b/bug-262309_xcb-xauthlocalhostname.diff index 7182d05..ffd3eb7 100644 --- a/bug-262309_xcb-xauthlocalhostname.diff +++ b/bug-262309_xcb-xauthlocalhostname.diff @@ -1,27 +1,24 @@ --- src/xcb_auth.c.orig 2009-05-29 17:48:24.000000000 +0200 +++ src/xcb_auth.c 2009-05-29 17:56:01.000000000 +0200 -@@ -100,2 +100,3 @@ static Xauth *get_authptr(struct sockadd +@@ -119,2 +119,3 @@ static Xauth *get_authptr(struct sockadd int dispbuflen; + Xauth *authptr = NULL; -@@ -143,6 +143,16 @@ static Xauth *get_authptr(struct sockadd +@@ -163,6 +163,16 @@ static Xauth *get_authptr(struct sockadd - return XauGetBestAuthByAddr (family, -- (unsigned short) addrlen, addr, -- (unsigned short) dispbuflen, dispbuf, -- N_AUTH_PROTOS, authnames, authnameslen); + authptr = XauGetBestAuthByAddr (family, -+ (unsigned short) addrlen, addr, -+ (unsigned short) dispbuflen, dispbuf, -+ N_AUTH_PROTOS, authnames, authnameslen); + (unsigned short) addrlen, addr, + (unsigned short) dispbuflen, dispbuf, + N_AUTH_PROTOS, authnames, authnameslen); + // && !phostname + if ((!authptr || !authptr->data_length) && family == FamilyLocal) { -+ if ( (addr = getenv("XAUTHLOCALHOSTNAME")) ) { -+ authptr = XauGetBestAuthByAddr (family, -+ (unsigned short) strlen(addr), addr, -+ (unsigned short) dispbuflen, dispbuf, -+ N_AUTH_PROTOS, authnames, authnameslen); -+ } ++ if ( (addr = getenv("XAUTHLOCALHOSTNAME")) ) { ++ authptr = XauGetBestAuthByAddr (family, ++ (unsigned short) strlen(addr), addr, ++ (unsigned short) dispbuflen, dispbuf, ++ N_AUTH_PROTOS, authnames, authnameslen); ++ } + } + return authptr; } diff --git a/libxcb.changes b/libxcb.changes index c2e63c5..249d310 100644 --- a/libxcb.changes +++ b/libxcb.changes @@ -1,3 +1,21 @@ +------------------------------------------------------------------- +Fri Jan 5 10:44:07 UTC 2018 - msrb@suse.com + +- n_If-auth-with-credentials-for-hostname-fails-retry-with-XAUTHLOCALHOSTNAME.patch + * Prevent infinite loop also in case DISPLAY is non-local. + +------------------------------------------------------------------- +Wed Dec 20 21:07:38 UTC 2017 - aaronpuchert@alice-dsl.net + +- Use spaces instead of tabs in the patches (as does the original + source code) to avoid confusion. +- n_If-auth-with-credentials-for-hostname-fails-retry-with-XAUTHLOCALHOSTNAME.patch + * If authentication (with *stage == 0) failed and the variable + XAUTHLOCALHOSTNAME wasn't set, we were never getting to stage 2 + in the original patch, causing calls to xcb_connect_to_display + to be stuck in an infinite loop. + Now we also go to stage 2 if the variable isn't set. + ------------------------------------------------------------------- Mon Dec 11 12:13:21 UTC 2017 - sndirsch@suse.com diff --git a/libxcb.spec b/libxcb.spec index 47d40fa..e298fb0 100644 --- a/libxcb.spec +++ b/libxcb.spec @@ -1,7 +1,7 @@ # # spec file for package libxcb # -# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed diff --git a/n_If-auth-with-credentials-for-hostname-fails-retry-with-XAUTHLOCALHOSTNAME.patch b/n_If-auth-with-credentials-for-hostname-fails-retry-with-XAUTHLOCALHOSTNAME.patch index 2475558..f1f7774 100644 --- a/n_If-auth-with-credentials-for-hostname-fails-retry-with-XAUTHLOCALHOSTNAME.patch +++ b/n_If-auth-with-credentials-for-hostname-fails-retry-with-XAUTHLOCALHOSTNAME.patch @@ -29,37 +29,42 @@ Index: libxcb-1.12/src/xcb_auth.c Xauth *authptr = NULL; + if (*stage == 2) -+ return NULL; ++ return NULL; family = FamilyLocal; /* 256 */ switch(sockname->sa_family) { -@@ -161,10 +163,13 @@ static Xauth *get_authptr(struct sockadd +@@ -161,18 +163,23 @@ static Xauth *get_authptr(struct sockadd addrlen = strlen(addr); } - authptr = XauGetBestAuthByAddr (family, -- (unsigned short) addrlen, addr, -- (unsigned short) dispbuflen, dispbuf, -- N_AUTH_PROTOS, authnames, authnameslen); +- (unsigned short) addrlen, addr, +- (unsigned short) dispbuflen, dispbuf, +- N_AUTH_PROTOS, authnames, authnameslen); +- // && !phostname +- if ((!authptr || !authptr->data_length) && family == FamilyLocal) { +- if ( (addr = getenv("XAUTHLOCALHOSTNAME")) ) { + if (*stage == 0) { -+ authptr = XauGetBestAuthByAddr (family, -+ (unsigned short) addrlen, addr, -+ (unsigned short) dispbuflen, dispbuf, -+ N_AUTH_PROTOS, authnames, authnameslen); -+ *stage = 1; ++ authptr = XauGetBestAuthByAddr (family, ++ (unsigned short) addrlen, addr, ++ (unsigned short) dispbuflen, dispbuf, ++ N_AUTH_PROTOS, authnames, authnameslen); ++ *stage = 1; ++ return authptr; + } - // && !phostname - if ((!authptr || !authptr->data_length) && family == FamilyLocal) { - if ( (addr = getenv("XAUTHLOCALHOSTNAME")) ) { -@@ -172,6 +177,7 @@ static Xauth *get_authptr(struct sockadd - (unsigned short) strlen(addr), addr, - (unsigned short) dispbuflen, dispbuf, - N_AUTH_PROTOS, authnames, authnameslen); -+ *stage = 2; - } ++ if (*stage == 1) { ++ if ((!authptr || !authptr->data_length) && family == FamilyLocal && (addr = getenv("XAUTHLOCALHOSTNAME"))) { + authptr = XauGetBestAuthByAddr (family, + (unsigned short) strlen(addr), addr, + (unsigned short) dispbuflen, dispbuf, + N_AUTH_PROTOS, authnames, authnameslen); + } ++ *stage = 2; ++ return authptr; } return authptr; -@@ -320,7 +326,7 @@ static struct sockaddr *get_peer_sock_na + } +@@ -320,7 +327,7 @@ static struct sockaddr *get_peer_sock_na return NULL; } @@ -68,7 +73,7 @@ Index: libxcb-1.12/src/xcb_auth.c { /* code adapted from Xlib/ConnDis.c, xtrans/Xtranssocket.c, xtrans/Xtransutils.c */ -@@ -345,7 +351,7 @@ int _xcb_get_auth_info(int fd, xcb_auth_ +@@ -345,7 +352,7 @@ int _xcb_get_auth_info(int fd, xcb_auth_ gotsockname = 1; }