summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.sbin/traceroute6/traceroute6.c42
1 files changed, 21 insertions, 21 deletions
diff --git a/usr.sbin/traceroute6/traceroute6.c b/usr.sbin/traceroute6/traceroute6.c
index 8f8aed2ba12..669849e1f2b 100644
--- a/usr.sbin/traceroute6/traceroute6.c
+++ b/usr.sbin/traceroute6/traceroute6.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: traceroute6.c,v 1.30 2002/10/23 06:45:13 mark Exp $ */
-/* $KAME: traceroute6.c,v 1.61 2002/09/08 01:28:05 itojun Exp $ */
+/* $OpenBSD: traceroute6.c,v 1.31 2002/10/24 12:58:45 itojun Exp $ */
+/* $KAME: traceroute6.c,v 1.63 2002/10/24 12:53:25 itojun Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -422,18 +422,13 @@ main(argc, argv)
break;
case 'f':
ep = NULL;
+ errno = 0;
first_hop = strtoul(optarg, &ep, 0);
- if (!*argv || *ep) {
+ if (errno || !*optarg || *ep|| first_hop > 255) {
fprintf(stderr,
"traceroute6: invalid min hoplimit.\n");
exit(1);
}
- if (first_hop > max_hops) {
- fprintf(stderr,
- "traceroute6: min hoplimit must be <= %lu.\n",
- max_hops);
- exit(1);
- }
break;
case 'g':
hp = getipnodebyname(optarg, AF_INET6, 0, &h_errno);
@@ -480,27 +475,23 @@ main(argc, argv)
break;
case 'm':
ep = NULL;
+ errno = 0;
max_hops = strtoul(optarg, &ep, 0);
- if (!*argv || *ep) {
+ if (errno || !*optarg || *ep || max_hops > 255) {
fprintf(stderr,
"traceroute6: invalid max hoplimit.\n");
exit(1);
}
- if (max_hops < first_hop) {
- fprintf(stderr,
- "traceroute6: max hoplimit must be >= %lu.\n",
- first_hop);
- exit(1);
- }
break;
case 'n':
nflag++;
break;
case 'p':
ep = NULL;
+ errno = 0;
lport = strtoul(optarg, &ep, 0);
- if (!*argv || *ep) {
- fprintf(stderr, "traceroute6: port.\n");
+ if (errno || !*optarg || *ep) {
+ fprintf(stderr, "traceroute6: invalid port.\n");
exit(1);
}
if (lport == 0 || lport != (lport & 0xffff)) {
@@ -512,8 +503,9 @@ main(argc, argv)
break;
case 'q':
ep = NULL;
+ errno = 0;
nprobes = strtoul(optarg, &ep, 0);
- if (!*argv || *ep) {
+ if (errno || !*optarg || *ep) {
fprintf(stderr,
"traceroute6: invalid nprobes.\n");
exit(1);
@@ -539,8 +531,9 @@ main(argc, argv)
break;
case 'w':
ep = NULL;
+ errno = 0;
waittime = strtoul(optarg, &ep, 0);
- if (!*argv || *ep) {
+ if (errno || !*optarg || *ep) {
fprintf(stderr,
"traceroute6: invalid wait time.\n");
exit(1);
@@ -557,6 +550,12 @@ main(argc, argv)
argc -= optind;
argv += optind;
+ if (max_hops < first_hop) {
+ fprintf(stderr,
+ "traceroute6: max hoplimit must be larger than first hoplimit.\n");
+ exit(1);
+ }
+
if (argc < 1 || argc > 2)
usage();
@@ -598,8 +597,9 @@ main(argc, argv)
if (*++argv) {
ep = NULL;
+ errno = 0;
datalen = strtoul(*argv, &ep, 0);
- if (!*argv || *ep) {
+ if (errno || !*argv || *ep) {
fprintf(stderr,
"traceroute6: invalid packet length.\n");
exit(1);