From b7e04c00612229e1d0f4ebc6c2c4df6228622510 Mon Sep 17 00:00:00 2001 From: Bart Massey Date: Wed, 8 Apr 2009 23:17:51 -0700 Subject: [PATCH] fixed auth data from wrong end of connection --- src/xcb_auth.c | 28 +++++++++++++++++----------- 1 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/xcb_auth.c b/src/xcb_auth.c index 93a6f68..c967fe7 100644 --- a/src/xcb_auth.c +++ b/src/xcb_auth.c @@ -242,23 +242,29 @@ int _xcb_get_auth_info(int fd, xcb_auth_info_t *info, int display) Xauth *authptr = 0; int ret = 1; - if (getpeername(fd, sockname, &socknamelen) == -1) - { - if (getsockname(fd, sockname, &socknamelen) == -1) - return 0; /* can only authenticate sockets */ - if (sockname->sa_family != AF_UNIX) - return 0; - /* Some systems like hpux or Hurd do not expose peer names - * for UNIX Domain Sockets. We do not need it anyway. */ - } + if (getsockname(fd, sockname, &socknamelen) == -1) + return 0; /* can only authenticate sockets */ authptr = get_authptr(sockname, socknamelen, display); if (authptr == 0) return 0; /* cannot find good auth data */ info->namelen = memdup(&info->name, authptr->name, authptr->name_length); - if(info->namelen) - ret = compute_auth(info, authptr, sockname); + if (!info->namelen) + { + XauDisposeAuth(authptr); + return 0; + } + + /* Some systems like hpux or Hurd do not expose peer names + * for UNIX Domain Sockets, but this is irrelevant, + * since compute_auth() ignores the peer name in this + * case anyway.*/ + if (sockname->sa_family != AF_UNIX) + if (getpeername(fd, sockname, &socknamelen) == -1) + return 0; + + ret = compute_auth(info, authptr, sockname); if(!ret) { free(info->name); -- 1.6.2.1