diff options
author | marha <marha@users.sourceforge.net> | 2011-12-17 13:46:47 +0100 |
---|---|---|
committer | Marc Haesen <marc@hc-consult.be> | 2011-12-17 13:46:47 +0100 |
commit | cd55591be471b59faf9693651837a61e8376d85a (patch) | |
tree | daa8bcdb500384d7112f5114bf9c11b0bc2ab78d /X11 | |
parent | 1ae4005bfe3690b34ec40e33918b3e24468d47e1 (diff) | |
parent | abacebe06d9f3d2fe1b7d256bd86cddbfa592a85 (diff) | |
download | vcxsrv-cd55591be471b59faf9693651837a61e8376d85a.tar.gz vcxsrv-cd55591be471b59faf9693651837a61e8376d85a.tar.bz2 vcxsrv-cd55591be471b59faf9693651837a61e8376d85a.zip |
Merge remote-tracking branch 'origin/released'
Diffstat (limited to 'X11')
-rw-r--r-- | X11/xtrans/Xtranssock.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/X11/xtrans/Xtranssock.c b/X11/xtrans/Xtranssock.c index bb7ece4c2..3a151ecfe 100644 --- a/X11/xtrans/Xtranssock.c +++ b/X11/xtrans/Xtranssock.c @@ -466,6 +466,7 @@ TRANS(SocketReopen) (int i _X_UNUSED, int type, int fd, char *port) XtransConnInfo ciptr; int portlen; struct sockaddr *addr; + size_t addrlen; prmsg (3,"SocketReopen(%d,%d,%s)\n", type, fd, port); @@ -496,26 +497,27 @@ TRANS(SocketReopen) (int i _X_UNUSED, int type, int fd, char *port) ciptr->fd = fd; - if ((addr = calloc (1, portlen + 2)) == NULL) { + addrlen = portlen + offsetof(struct sockaddr, sa_data); + if ((addr = calloc (1, addrlen)) == NULL) { prmsg (1, "SocketReopen: malloc(addr) failed\n"); free (ciptr); return NULL; } ciptr->addr = (char *) addr; - ciptr->addrlen = portlen + 2; + ciptr->addrlen = addrlen; - if ((ciptr->peeraddr = calloc (1, portlen + 2)) == NULL) { + if ((ciptr->peeraddr = calloc (1, addrlen)) == NULL) { prmsg (1, "SocketReopen: malloc(portaddr) failed\n"); free (addr); free (ciptr); return NULL; } - ciptr->peeraddrlen = portlen + 2; + ciptr->peeraddrlen = addrlen; /* Initialize ciptr structure as if it were a normally-opened unix socket */ ciptr->flags = TRANS_LOCAL | TRANS_NOUNLINK; #ifdef BSD44SOCKETS - addr->sa_len = portlen + 1; + addr->sa_len = addrlen; #endif addr->sa_family = AF_UNIX; #ifdef HAS_STRLCPY @@ -524,7 +526,7 @@ TRANS(SocketReopen) (int i _X_UNUSED, int type, int fd, char *port) strncpy(addr->sa_data, port, portlen); #endif ciptr->family = AF_UNIX; - memcpy(ciptr->peeraddr, ciptr->addr, sizeof(struct sockaddr)); + memcpy(ciptr->peeraddr, ciptr->addr, addrlen); ciptr->port = rindex(addr->sa_data, ':'); if (ciptr->port == NULL) { if (is_numeric(addr->sa_data)) { |