diff options
-rw-r--r-- | Makefile.am | 4 | ||||
-rw-r--r-- | Makefile.bsd-wrapper | 5 | ||||
-rw-r--r-- | Xtrans.c | 3 | ||||
-rw-r--r-- | Xtranssock.c | 2 | ||||
-rw-r--r-- | Xtransutil.c | 28 |
5 files changed, 28 insertions, 14 deletions
diff --git a/Makefile.am b/Makefile.am index 3a719f8..b57bf71 100644 --- a/Makefile.am +++ b/Makefile.am @@ -10,10 +10,10 @@ Xtransinclude_HEADERS = \ Xtransutil.c \ transport.c -aclocaldir = $(datadir)/aclocal +aclocaldir = $(libdir)/aclocal aclocal_DATA = xtrans.m4 -pkgconfigdir = $(datadir)/pkgconfig +pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = xtrans.pc MAINTAINERCLEANFILES = ChangeLog INSTALL diff --git a/Makefile.bsd-wrapper b/Makefile.bsd-wrapper new file mode 100644 index 0000000..7a2f498 --- /dev/null +++ b/Makefile.bsd-wrapper @@ -0,0 +1,5 @@ +# $OpenBSD: Makefile.bsd-wrapper,v 1.3 2012/03/10 18:41:37 matthieu Exp $ + +CONFIGURE_ARGS += --without-fop --without-xmlto + +.include <bsd.xorg.mk> @@ -208,6 +208,7 @@ TRANS(ParseAddress) (const char *address, char hostnamebuf[256]; char *_host_buf; int _host_len; + size_t len; prmsg (3,"ParseAddress(%s)\n", address); @@ -501,6 +502,7 @@ TRANS(Reopen) (int type, int trans_id, int fd, const char *port) Xtransport *thistrans = NULL; char *save_port; int i; + size_t len; prmsg (2,"Reopen(%d,%d,%s)\n", trans_id, fd, port); @@ -604,6 +606,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 9482ecf..4dca2d6 100644 --- a/Xtranssock.c +++ b/Xtranssock.c @@ -923,7 +923,7 @@ TRANS(SocketINETCreateListener) (XtransConnInfo ciptr, const char *port, } 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 884cfdf..c83e029 100644 --- a/Xtransutil.c +++ b/Xtransutil.c @@ -196,7 +196,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; @@ -236,6 +236,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) { @@ -248,9 +249,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; } @@ -278,9 +280,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) */ @@ -318,6 +322,7 @@ TRANS(GetPeerNetworkId) (XtransConnInfo ciptr) char *hostname; char addrbuf[256]; const char *addr = NULL; + size_t len; switch (family) { @@ -398,12 +403,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); } |