diff options
author | peter <peter@FreeBSD.org> | 1997-06-27 08:22:03 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 1997-06-27 08:22:03 +0000 |
commit | 63d61ea6e9374a89adcb36c3f5c3b759b9a82c41 (patch) | |
tree | 42dba341377c853de43567a145b2a902b2039b15 /lib/libc/net/res_query.c | |
parent | 20250d8619bb0419032ebda7ca41de01e60bea7f (diff) | |
download | FreeBSD-src-63d61ea6e9374a89adcb36c3f5c3b759b9a82c41.zip FreeBSD-src-63d61ea6e9374a89adcb36c3f5c3b759b9a82c41.tar.gz |
Merge in bind-4.9.6 resolver changes. Note that they resolve the
overflow problem differently.
Diffstat (limited to 'lib/libc/net/res_query.c')
-rw-r--r-- | lib/libc/net/res_query.c | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/lib/libc/net/res_query.c b/lib/libc/net/res_query.c index 9726299..8110895 100644 --- a/lib/libc/net/res_query.c +++ b/lib/libc/net/res_query.c @@ -55,8 +55,8 @@ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)res_query.c 8.1 (Berkeley) 6/4/93"; -static char orig_rcsid = "From: Id: res_query.c,v 8.9 1996/09/22 00:13:28 vixie Exp"; -static char rcsid[] = "$Id: res_query.c,v 1.12 1997/02/22 15:00:34 peter Exp $"; +static char orig_rcsid = "From: Id: res_query.c,v 8.10 1997/06/01 20:34:37 vixie Exp"; +static char rcsid[] = "$Id: res_query.c,v 1.13 1997/03/24 06:11:44 imp Exp $"; #endif /* LIBC_SCCS and not lint */ #include <sys/types.h> @@ -318,7 +318,7 @@ res_querydomain(name, domain, class, type, answer, anslen) { char nbuf[MAXDNAME]; const char *longname = nbuf; - int n; + int n, d; if ((_res.options & RES_INIT) == 0 && res_init() == -1) { h_errno = NETDB_INTERNAL; @@ -334,15 +334,26 @@ res_querydomain(name, domain, class, type, answer, anslen) * Check for trailing '.'; * copy without '.' if present. */ - n = strlen(name) - 1; - if (n != (0 - 1) && name[n] == '.' && n < sizeof(nbuf) - 1) { - bcopy(name, nbuf, n); + n = strlen(name); + if (n >= MAXDNAME) { + h_errno = NO_RECOVERY; + return (-1); + } + n--; + if (n >= 0 && name[n] == '.') { + strncpy(nbuf, name, n); nbuf[n] = '\0'; } else longname = name; - } else - sprintf(nbuf, "%.*s.%.*s", MAXDNAME, name, MAXDNAME, domain); - + } else { + n = strlen(name); + d = strlen(domain); + if (n + d + 1 >= MAXDNAME) { + h_errno = NO_RECOVERY; + return (-1); + } + sprintf(nbuf, "%s.%s", name, domain); + } return (res_query(longname, class, type, answer, anslen)); } |