summaryrefslogtreecommitdiff
path: root/usr.sbin/named/dnsquery/dnsquery.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/named/dnsquery/dnsquery.c')
-rw-r--r--usr.sbin/named/dnsquery/dnsquery.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/usr.sbin/named/dnsquery/dnsquery.c b/usr.sbin/named/dnsquery/dnsquery.c
index 4a8e42bf0ec..7a61479940a 100644
--- a/usr.sbin/named/dnsquery/dnsquery.c
+++ b/usr.sbin/named/dnsquery/dnsquery.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dnsquery.c,v 1.3 1997/03/12 10:41:49 downsj Exp $ */
+/* $OpenBSD: dnsquery.c,v 1.4 1999/12/04 00:22:34 deraadt Exp $ */
#include <stdio.h>
#include <sys/types.h>
@@ -53,7 +53,12 @@ char *argv[];
case 'p' : _res.retrans = atoi(optarg);
break;
- case 'h' : strcpy(name, optarg);
+ case 'h' : if (strlen(optarg) > sizeof(name)-1) {
+ fprintf(stderr,
+ "Domain name too long (%s)\n", optarg);
+ exit(-1);
+ }
+ strlcpy(name, optarg, sizeof name);
break;
case 'c' : {
@@ -130,8 +135,14 @@ char *argv[];
exit(-1);
}
}
- if (optind < argc)
- strcpy(name, argv[optind]);
+ if (optind < argc) {
+ if (strlen(argv[optind]) > sizeof(name)-1) {
+ fprintf(stderr,
+ "Domain name too long (%s)\n", argv[optind]);
+ exit(-1);
+ }
+ strlcpy(name, argv[optind], sizeof name);
+ }
len = sizeof(answer);