summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.bsd-wrapper5
-rw-r--r--Xtrans.c3
-rw-r--r--Xtranssock.c2
-rw-r--r--Xtransutil.c28
4 files changed, 26 insertions, 12 deletions
diff --git a/Makefile.bsd-wrapper b/Makefile.bsd-wrapper
new file mode 100644
index 0000000..83b7928
--- /dev/null
+++ b/Makefile.bsd-wrapper
@@ -0,0 +1,5 @@
+# $OpenBSD: Makefile.bsd-wrapper,v 1.1 2006/11/26 12:07:34 matthieu Exp $
+
+CONFIGURE_ARGS += --without-groff
+
+.include <bsd.xorg.mk>
diff --git a/Xtrans.c b/Xtrans.c
index 7c7967f..6282b96 100644
--- a/Xtrans.c
+++ b/Xtrans.c
@@ -202,6 +202,7 @@ TRANS(ParseAddress) (char *address, char **protocol, char **host, char **port)
char *_host, *_port;
char hostnamebuf[256];
int _host_len;
+ size_t len;
prmsg (3,"ParseAddress(%s)\n", address);
@@ -491,6 +492,7 @@ TRANS(Reopen) (int type, int trans_id, int fd, char *port)
Xtransport *thistrans = NULL;
char *save_port;
int i;
+ size_t len;
prmsg (2,"Reopen(%d,%d,%s)\n", trans_id, fd, port);
@@ -632,6 +634,7 @@ TRANS(GetReopenInfo) (XtransConnInfo ciptr,
{
int i;
+ size_t len;
for (i = 0; i < NUMTRANS; i++)
if (Xtransports[i].transport == ciptr->transptr)
diff --git a/Xtranssock.c b/Xtranssock.c
index 23150b2..fd3bb3c 100644
--- a/Xtranssock.c
+++ b/Xtranssock.c
@@ -1015,7 +1015,7 @@ TRANS(SocketINETCreateListener) (XtransConnInfo ciptr, char *port, unsigned int
} else {
namelen = sizeof (struct sockaddr_in6);
#ifdef SIN6_LEN
- ((struct sockaddr_in6 *)&sockname)->sin6_len = sizeof(sockname);
+ ((struct sockaddr_in6 *)&sockname)->sin6_len = (u_int8_t)sizeof(sockname);
#endif
((struct sockaddr_in6 *)&sockname)->sin6_family = AF_INET6;
((struct sockaddr_in6 *)&sockname)->sin6_port = htons(sport);
diff --git a/Xtransutil.c b/Xtransutil.c
index a6928bb..dba1cd4 100644
--- a/Xtransutil.c
+++ b/Xtransutil.c
@@ -203,7 +203,7 @@ TRANS(ConvertAddress)(int *familyp, int *addrlenp, Xtransaddr **addrp)
if (!*addrp)
*addrp = malloc (len + 1);
if (*addrp) {
- strcpy ((char *) *addrp, hostnamebuf);
+ strlcpy ((char *) *addrp, hostnamebuf, len + 1);
*addrlenp = len;
} else {
*addrlenp = 0;
@@ -243,6 +243,7 @@ TRANS(GetMyNetworkId) (XtransConnInfo ciptr)
char hostnamebuf[256];
char *networkId = NULL;
const char *transName = ciptr->transptr->TransName;
+ size_t len;
if (gethostname (hostnamebuf, sizeof (hostnamebuf)) < 0)
{
@@ -255,9 +256,10 @@ TRANS(GetMyNetworkId) (XtransConnInfo ciptr)
case AF_UNIX:
{
struct sockaddr_un *saddr = (struct sockaddr_un *) addr;
- networkId = malloc (3 + strlen (transName) +
- strlen (hostnamebuf) + strlen (saddr->sun_path));
- sprintf (networkId, "%s/%s:%s", transName,
+ len = 3 + strlen (transName) +
+ strlen (hostnamebuf) + strlen (saddr->sun_path);
+ networkId = malloc (len);
+ snprintf (networkId, len, "%s/%s:%s", transName,
hostnamebuf, saddr->sun_path);
break;
}
@@ -285,9 +287,11 @@ TRANS(GetMyNetworkId) (XtransConnInfo ciptr)
portnum = ntohs (saddr->sin_port);
snprintf (portnumbuf, sizeof(portnumbuf), "%d", portnum);
- networkId = malloc (3 + strlen (transName) +
- strlen (hostnamebuf) + strlen (portnumbuf));
- sprintf (networkId, "%s/%s:%s", transName, hostnamebuf, portnumbuf);
+ len = 3 + strlen (transName) +
+ strlen (hostnamebuf) + strlen (portnumbuf);
+ networkId = malloc (len);
+ snprintf (networkId, len, "%s/%s:%s", transName, hostnamebuf,
+ portnumbuf);
break;
}
#endif /* defined(TCPCONN) */
@@ -337,6 +341,7 @@ TRANS(GetPeerNetworkId) (XtransConnInfo ciptr)
char *hostname;
char addrbuf[256];
const char *addr = NULL;
+ size_t len;
switch (family)
{
@@ -417,12 +422,13 @@ TRANS(GetPeerNetworkId) (XtransConnInfo ciptr)
return (NULL);
}
+ len = strlen (ciptr->transptr->TransName) + strlen (addr) + 2;
+ hostname = malloc (len);
+ strlcpy (hostname, ciptr->transptr->TransName, len);
+ strlcat (hostname, "/", len);
- hostname = malloc (strlen (ciptr->transptr->TransName) + strlen (addr) + 2);
- strcpy (hostname, ciptr->transptr->TransName);
- strcat (hostname, "/");
if (addr)
- strcat (hostname, addr);
+ strlcat (hostname, addr, len);
return (hostname);
}