summaryrefslogtreecommitdiffstats
path: root/lib/libc/net
diff options
context:
space:
mode:
authornectar <nectar@FreeBSD.org>2003-04-29 21:13:50 +0000
committernectar <nectar@FreeBSD.org>2003-04-29 21:13:50 +0000
commite69967f5348cec651f8806d25d2c59ac8ed8c2a2 (patch)
treee9749f1ff2693755bce73e10528fc8cc6a6563ea /lib/libc/net
parent975e4bcef1ba69d85a5c90f1849accc3cd74cb65 (diff)
downloadFreeBSD-src-e69967f5348cec651f8806d25d2c59ac8ed8c2a2.zip
FreeBSD-src-e69967f5348cec651f8806d25d2c59ac8ed8c2a2.tar.gz
`Hide' strlcpy and strlcat (using the namespace.h / __weak_reference
technique) so that we don't wind up calling into an application's version if the application defines them. Inspired by: qpopper's interfering and buggy version of strlcpy
Diffstat (limited to 'lib/libc/net')
-rw-r--r--lib/libc/net/getaddrinfo.c4
-rw-r--r--lib/libc/net/gethostbydns.c6
-rw-r--r--lib/libc/net/getnameinfo.c12
-rw-r--r--lib/libc/net/hesiod.c4
-rw-r--r--lib/libc/net/if_nametoindex.c2
5 files changed, 17 insertions, 11 deletions
diff --git a/lib/libc/net/getaddrinfo.c b/lib/libc/net/getaddrinfo.c
index e2cb71a..2b8708a 100644
--- a/lib/libc/net/getaddrinfo.c
+++ b/lib/libc/net/getaddrinfo.c
@@ -853,7 +853,7 @@ get_canonname(pai, ai, str)
ai->ai_canonname = (char *)malloc(strlen(str) + 1);
if (ai->ai_canonname == NULL)
return EAI_MEMORY;
- strlcpy(ai->ai_canonname, str, strlen(str) + 1);
+ _strlcpy(ai->ai_canonname, str, strlen(str) + 1);
}
return 0;
}
@@ -1305,7 +1305,7 @@ getanswer(answer, anslen, qname, qtype, pai)
had_error++;
continue;
}
- strlcpy(bp, tbuf, ep - bp);
+ _strlcpy(bp, tbuf, ep - bp);
canonname = bp;
bp += n;
continue;
diff --git a/lib/libc/net/gethostbydns.c b/lib/libc/net/gethostbydns.c
index 02cd223..9eeba2f 100644
--- a/lib/libc/net/gethostbydns.c
+++ b/lib/libc/net/gethostbydns.c
@@ -60,6 +60,7 @@ static char fromrcsid[] = "From: Id: gethnamaddr.c,v 8.23 1998/04/07 04:59:46 vi
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include "namespace.h"
#include <sys/types.h>
#include <sys/param.h>
#include <sys/socket.h>
@@ -78,6 +79,7 @@ __FBSDID("$FreeBSD$");
#include <syslog.h>
#include <stdarg.h>
#include <nsswitch.h>
+#include "un-namespace.h"
#include "res_config.h"
@@ -674,7 +676,7 @@ _dns_gethostbyaddr(void *rval, void *cb_data, va_list ap)
uaddr[n] & 0xf,
(uaddr[n] >> 4) & 0xf));
}
- strlcat(qbuf, "ip6.arpa", sizeof(qbuf));
+ _strlcat(qbuf, "ip6.arpa", sizeof(qbuf));
break;
default:
abort();
@@ -686,7 +688,7 @@ _dns_gethostbyaddr(void *rval, void *cb_data, va_list ap)
n = res_query(qbuf, C_IN, T_PTR, (u_char *)buf->buf, sizeof buf->buf);
if (n < 0 && af == AF_INET6) {
*qp = '\0';
- strlcat(qbuf, "ip6.int", sizeof(qbuf));
+ _strlcat(qbuf, "ip6.int", sizeof(qbuf));
n = res_query(qbuf, C_IN, T_PTR, (u_char *)buf->buf,
sizeof buf->buf);
}
diff --git a/lib/libc/net/getnameinfo.c b/lib/libc/net/getnameinfo.c
index cee07f6..1aec5be 100644
--- a/lib/libc/net/getnameinfo.c
+++ b/lib/libc/net/getnameinfo.c
@@ -46,6 +46,7 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include "namespace.h"
#include <sys/types.h>
#include <sys/socket.h>
#include <net/if.h>
@@ -57,6 +58,7 @@ __FBSDID("$FreeBSD$");
#include <string.h>
#include <stddef.h>
#include <errno.h>
+#include "un-namespace.h"
static const struct afd {
int a_af;
@@ -145,12 +147,12 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
if (sp) {
if (strlen(sp->s_name) + 1 > servlen)
return EAI_MEMORY;
- strlcpy(serv, sp->s_name, servlen);
+ _strlcpy(serv, sp->s_name, servlen);
} else {
snprintf(numserv, sizeof(numserv), "%u", ntohs(port));
if (strlen(numserv) + 1 > servlen)
return EAI_MEMORY;
- strlcpy(serv, numserv, servlen);
+ _strlcpy(serv, numserv, servlen);
}
}
@@ -223,7 +225,7 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
numaddrlen = strlen(numaddr);
if (numaddrlen + 1 > hostlen) /* don't forget terminator */
return EAI_MEMORY;
- strlcpy(host, numaddr, hostlen);
+ _strlcpy(host, numaddr, hostlen);
break;
}
} else {
@@ -246,7 +248,7 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
freehostent(hp);
return EAI_MEMORY;
}
- strlcpy(host, hp->h_name, hostlen);
+ _strlcpy(host, hp->h_name, hostlen);
freehostent(hp);
} else {
if (flags & NI_NAMEREQD)
@@ -293,7 +295,7 @@ ip6_parsenumeric(sa, addr, host, hostlen, flags)
numaddrlen = strlen(numaddr);
if (numaddrlen + 1 > hostlen) /* don't forget terminator */
return EAI_MEMORY;
- strlcpy(host, numaddr, hostlen);
+ _strlcpy(host, numaddr, hostlen);
if (((const struct sockaddr_in6 *)sa)->sin6_scope_id) {
char zonebuf[MAXHOSTNAMELEN];
diff --git a/lib/libc/net/hesiod.c b/lib/libc/net/hesiod.c
index c22bdba..214f86e 100644
--- a/lib/libc/net/hesiod.c
+++ b/lib/libc/net/hesiod.c
@@ -51,6 +51,7 @@ static char *orig_rcsid = "$NetBSD: hesiod.c,v 1.9 1999/02/11 06:16:38 simonb Ex
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include "namespace.h"
#include <sys/types.h>
#include <sys/param.h>
#include <netinet/in.h>
@@ -64,6 +65,7 @@ __FBSDID("$FreeBSD$");
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include "un-namespace.h"
struct hesiod_p {
char *lhs; /* normally ".ns" */
@@ -163,7 +165,7 @@ hesiod_to_bind(void *context, const char *name, const char *type)
const char *rhs;
int len;
- if (strlcpy(bindname, name, sizeof(bindname)) >= sizeof(bindname)) {
+ if (_strlcpy(bindname, name, sizeof(bindname)) >= sizeof(bindname)) {
errno = EMSGSIZE;
return NULL;
}
diff --git a/lib/libc/net/if_nametoindex.c b/lib/libc/net/if_nametoindex.c
index d0ca521..887d64f 100644
--- a/lib/libc/net/if_nametoindex.c
+++ b/lib/libc/net/if_nametoindex.c
@@ -70,7 +70,7 @@ if_nametoindex(const char *ifname)
s = _socket(AF_INET, SOCK_DGRAM, 0);
if (s != -1) {
- strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
+ _strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
if (_ioctl(s, SIOCGIFINDEX, &ifr) != -1) {
_close(s);
return (ifr.ifr_index);
OpenPOWER on IntegriCloud