summaryrefslogtreecommitdiff
path: root/usr.sbin/named/dnsquery/dnsquery.c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1999-12-04 00:22:35 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1999-12-04 00:22:35 +0000
commita64909a2d7f7ce668a1531fa33db963234985274 (patch)
tree9bd6170d4ad5bb0f31f2de1873d7e3109430bf19 /usr.sbin/named/dnsquery/dnsquery.c
parent5ea16bbb3a422a9ca207322a33a736a11138b96f (diff)
avoid overflow
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);