summaryrefslogtreecommitdiffstats
path: root/lib/libc
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>1998-01-07 00:28:36 +0000
committerimp <imp@FreeBSD.org>1998-01-07 00:28:36 +0000
commitc15aab914445717e45e8260a65476aedd8d79614 (patch)
treede44b7a38ef1c67bd47f12729fdf888b7627d8be /lib/libc
parent683c0565d2607acaeb932b44ad8a624653b49c19 (diff)
downloadFreeBSD-src-c15aab914445717e45e8260a65476aedd8d79614.zip
FreeBSD-src-c15aab914445717e45e8260a65476aedd8d79614.tar.gz
handle long usernames more carefully
Reviewed by: guido Obtained from: OpenBSD (Theo de Raadt)
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/net/getnetbydns.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/libc/net/getnetbydns.c b/lib/libc/net/getnetbydns.c
index 2228a5c..bacdb67 100644
--- a/lib/libc/net/getnetbydns.c
+++ b/lib/libc/net/getnetbydns.c
@@ -60,7 +60,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)gethostnamadr.c 8.1 (Berkeley) 6/4/93";
-static char rcsid[] = "$Id: getnetbydns.c,v 1.10 1997/02/22 15:00:10 peter Exp $";
+static char rcsid[] = "$Id: getnetbydns.c,v 1.11 1997/06/27 08:22:01 peter Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
@@ -114,8 +114,9 @@ getnetanswer(answer, anslen, net_i)
register int n;
u_char *eom;
int type, class, buflen, ancount, qdcount, haveanswer, i, nchar;
- char aux1[30], aux2[30], ans[30], *in, *st, *pauxt, *bp, **ap,
- *paux1 = &aux1[0], *paux2 = &aux2[0], flag = 0;
+ char aux1[MAXHOSTNAMELEN], aux2[MAXHOSTNAMELEN], ans[MAXHOSTNAMELEN];
+ char *in, *st, *pauxt, *bp, **ap;
+ char *paux1 = &aux1[0], *paux2 = &aux2[0], flag = 0;
static struct netent net_entry;
static char *net_aliases[MAXALIASES], netbuf[PACKETSZ];
@@ -159,7 +160,8 @@ static char *net_aliases[MAXALIASES], netbuf[PACKETSZ];
break;
cp += n;
ans[0] = '\0';
- (void)strcpy(&ans[0], bp);
+ (void)strncpy(&ans[0], bp, sizeof(ans) - 1);
+ ans[sizeof(ans) - 1] = '\0';
GETSHORT(type, cp);
GETSHORT(class, cp);
cp += INT32SZ; /* TTL */
@@ -282,7 +284,8 @@ _getnetbydnsname(net)
h_errno = NETDB_INTERNAL;
return (NULL);
}
- strcpy(&qbuf[0], net);
+ strncpy(qbuf, net, sizeof(qbuf) - 1);
+ qbuf[sizeof(qbuf) - 1] = '\0';
anslen = res_search(qbuf, C_IN, T_PTR, (u_char *)&buf, sizeof(buf));
if (anslen < 0) {
#ifdef DEBUG
OpenPOWER on IntegriCloud