X-Git-Url: http://git.demorecorder.com/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fxcb_auth.c;h=859ab8a7619f9fc23016adb30aa084c3113d11bc;hb=163c47bdc0d32785d831e4c93fea9ab7e023446b;hp=1af27fc5d061641213aea6d31002fe08ca549123;hpb=20da10490f8dac75ec9fe1df28cb9e862e171be5;p=free-sw%2Fxcb%2Flibxcb diff --git a/src/xcb_auth.c b/src/xcb_auth.c index 1af27fc..859ab8a 100644 --- a/src/xcb_auth.c +++ b/src/xcb_auth.c @@ -30,6 +30,12 @@ #include #include #include +#include + +#ifdef __INTERIX +/* _don't_ ask. interix has INADDR_LOOPBACK in here. */ +#include +#endif #ifdef _WIN32 #include "xcb_windefs.h" @@ -261,7 +267,7 @@ static struct sockaddr *get_peer_sock_name(int (*socket_func)(int, { socklen_t socknamelen = sizeof(struct sockaddr) + INITIAL_SOCKNAME_SLACK; socklen_t actual_socknamelen = socknamelen; - struct sockaddr *sockname = malloc(socknamelen), *new_sockname = NULL; + struct sockaddr *sockname = malloc(socknamelen); if (sockname == NULL) return NULL; @@ -274,14 +280,17 @@ static struct sockaddr *get_peer_sock_name(int (*socket_func)(int, if (actual_socknamelen > socknamelen) { + struct sockaddr *new_sockname = NULL; socknamelen = actual_socknamelen; - if ((new_sockname = realloc(sockname, actual_socknamelen)) == NULL || - socket_func(fd, new_sockname, &actual_socknamelen) == -1 || - actual_socknamelen > socknamelen) + if ((new_sockname = realloc(sockname, actual_socknamelen)) == NULL) goto sock_or_realloc_error; sockname = new_sockname; + + if (socket_func(fd, sockname, &actual_socknamelen) == -1 || + actual_socknamelen > socknamelen) + goto sock_or_realloc_error; } return sockname; @@ -327,10 +336,15 @@ int _xcb_get_auth_info(int fd, xcb_auth_info_t *info, int display) if (!info->namelen) goto no_auth; /* out of memory */ - if (!gotsockname && (sockname = get_peer_sock_name(getsockname, fd)) == NULL) + if (!gotsockname) { - free(info->name); - goto no_auth; /* can only authenticate sockets */ + free(sockname); + + if ((sockname = get_peer_sock_name(getsockname, fd)) == NULL) + { + free(info->name); + goto no_auth; /* can only authenticate sockets */ + } } ret = compute_auth(info, authptr, sockname);