summaryrefslogtreecommitdiff
path: root/Xtranssock.c
diff options
context:
space:
mode:
authorDodji Seketeli <dodji@seketeli.org>2007-09-11 08:48:03 +0200
committerDodji Seketeli <dodji@seketeli.org>2007-09-11 08:48:03 +0200
commit88e141225113fcc4ebe5e8fe361e75673cdbf9ff (patch)
tree6b2d9f20121ff4e77d083eb8e8cbdc1c3dd56bd5 /Xtranssock.c
parent6217f34977bfa17b66b89df5d45420774abedcb3 (diff)
libxtrans: fix linux compilation breakage
* Xtranssock.c: (SocketReopen): protect use of BSD4.4 socket with BSD44SOCKETS macro. protect use of strlcnpy with HAVE_STRLCPY macro. That one is defined (or not) by the xserver configure.
Diffstat (limited to 'Xtranssock.c')
-rw-r--r--Xtranssock.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/Xtranssock.c b/Xtranssock.c
index e989b42..52f9aa1 100644
--- a/Xtranssock.c
+++ b/Xtranssock.c
@@ -172,6 +172,7 @@ static int IBMsockInit = 0;
#ifndef BACKLOG
#define BACKLOG MIN_BACKLOG
#endif
+
/*
* This is the Socket implementation of the X Transport service layer
*
@@ -540,12 +541,18 @@ TRANS(SocketReopen) (int i, int type, int fd, char *port)
}
portlen = strlen(port);
+#ifdef BSD44SOCKETS
if (portlen < 0 || portlen > (SOCK_MAXADDRLEN + 2)) {
PRMSG (1, "SocketReopen: invalid portlen %d\n", portlen, 0, 0);
return NULL;
}
-
if (portlen < 14) portlen = 14;
+#else
+ if (portlen < 0 || portlen > 14) {
+ PRMSG (1, "SocketReopen: invalid portlen %d\n", portlen, 0, 0);
+ return NULL;
+ }
+#endif /*BSD44SOCKETS*/
if ((ciptr = (XtransConnInfo) xcalloc (
1, sizeof(struct _XtransConnInfo))) == NULL)
@@ -571,9 +578,15 @@ TRANS(SocketReopen) (int i, int type, int fd, char *port)
/* Initialize ciptr structure as if it were a normally-opened unix socket */
ciptr->flags = TRANS_LOCAL;
+#ifdef BSD44SOCKETS
addr->sa_len = portlen + 1;
+#endif
addr->sa_family = AF_UNIX;
+#ifdef HAVE_STRLCPY
strlcpy(addr->sa_data, port, portlen);
+#else
+ strncpy(addr->sa_data, port, portlen);
+#endif
ciptr->family = AF_UNIX;
memcpy(ciptr->peeraddr, ciptr->addr, sizeof(struct sockaddr));
ciptr->port = rindex(addr->sa_data, ':');