From f79638411463f81b35d984f249d0f339e28fb712 Mon Sep 17 00:00:00 2001 From: Matthieu Herrb Date: Sat, 24 May 2008 16:57:29 +0200 Subject: OpenBSD fixes: snprintf/strlc{at,py} --- Xtranssock.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) (limited to 'Xtranssock.c') diff --git a/Xtranssock.c b/Xtranssock.c index 309839c..6b90040 100644 --- a/Xtranssock.c +++ b/Xtranssock.c @@ -296,9 +296,6 @@ static int TRANS(SocketINETClose) (XtransConnInfo ciptr); #if defined(IPv6) && defined(AF_INET6) static const struct in6_addr local_in6addr_any = IN6ADDR_ANY_INIT; #pragma weak in6addr_any = local_in6addr_any -#ifndef __USLC__ -#pragma weak getaddrinfo -#endif static int haveIPv6 = 1; #endif @@ -469,9 +466,6 @@ TRANS(SocketOpen) (int i, int type) PRMSG (3,"SocketOpen(%d,%d)\n", i, type, 0); #if defined(IPv6) && defined(AF_INET6) - if (getaddrinfo == NULL) - haveIPv6 = 0; - if (!haveIPv6 && Sockettrans2devtab[i].family == AF_INET6) return NULL; #endif @@ -905,7 +899,7 @@ set_sun_path(const char *port, const char *upath, char *path, int abstract) if (strlen(port) + strlen(upath) > maxlen) return -1; - sprintf(path, "%s%s%s", at, upath, port); + snprintf(path, "%s%s%s", maxlen+1, at, upath, port); return 0; } #endif @@ -1026,7 +1020,7 @@ TRANS(SocketINETCreateListener) (XtransConnInfo ciptr, char *port, unsigned int { /* fixup the server port address */ tmpport = X_TCP_PORT + strtol (port, (char**)NULL, 10); - sprintf (portbuf,"%lu", tmpport); + snprintf (portbuf, sizeof(portbuf), "%lu", tmpport); port = portbuf; } #endif @@ -1078,7 +1072,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); @@ -1531,7 +1525,7 @@ TRANS(SocketINETConnect) (XtransConnInfo ciptr, char *host, char *port) if (is_numeric (port)) { tmpport = X_TCP_PORT + strtol (port, (char**)NULL, 10); - sprintf (portbuf, "%lu", tmpport); + snprintf (portbuf, sizeof(portbuf), "%lu", tmpport); port = portbuf; } #endif @@ -1888,11 +1882,6 @@ UnixHostReallyLocal (char *host) { char hostnamebuf[256]; -#if defined(IPv6) && defined(AF_INET6) - if (getaddrinfo == NULL) - haveIPv6 = 0; -#endif - TRANS(GetHostname) (hostnamebuf, sizeof (hostnamebuf)); if (strcmp (hostnamebuf, host) == 0) -- cgit v1.2.3