summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoritojun <itojun@openbsd.org>2002-06-29 07:46:11 +0000
committeritojun <itojun@openbsd.org>2002-06-29 07:46:11 +0000
commita881e64fd342658867733e4ef524f49c1ce7c18b (patch)
tree6ef84c329dc72f5d526f77fae02b998beb2e126d
parentansi (diff)
downloadwireguard-openbsd-a881e64fd342658867733e4ef524f49c1ce7c18b.tar.xz
wireguard-openbsd-a881e64fd342658867733e4ef524f49c1ce7c18b.zip
check -p out of range. sync w/kame, hint from deraadt
-rw-r--r--usr.sbin/traceroute6/traceroute6.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/usr.sbin/traceroute6/traceroute6.c b/usr.sbin/traceroute6/traceroute6.c
index eabad025dd2..1e1f1821946 100644
--- a/usr.sbin/traceroute6/traceroute6.c
+++ b/usr.sbin/traceroute6/traceroute6.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: traceroute6.c,v 1.24 2002/06/09 02:39:17 itojun Exp $ */
+/* $OpenBSD: traceroute6.c,v 1.25 2002/06/29 07:46:11 itojun Exp $ */
/* $KAME: traceroute6.c,v 1.50 2002/05/26 13:12:07 itojun Exp $ */
/*
@@ -342,8 +342,8 @@ char *hostname;
int nprobes = 3;
int first_hop = 1;
int max_hops = 30;
-u_short srcport;
-u_short port = 32768+666; /* start udp dest port # for probe packets */
+u_int16_t srcport;
+u_int16_t port = 32768+666; /* start udp dest port # for probe packets */
int options; /* socket options */
int verbose;
int waittime = 5; /* time to wait for response (in seconds) */
@@ -364,6 +364,7 @@ main(argc, argv)
char *ep;
int mib[4] = { CTL_NET, PF_INET6, IPPROTO_IPV6, IPV6CTL_DEFHLIM };
size_t size = sizeof(max_hops);
+ u_long lport;
/*
* Receive ICMP
@@ -485,16 +486,17 @@ main(argc, argv)
break;
case 'p':
ep = NULL;
- port = strtoul(optarg, &ep, 0);
+ lport = strtoul(optarg, &ep, 0);
if (!*argv || *ep) {
fprintf(stderr, "traceroute6: port.\n");
exit(1);
}
- if (port < 1) {
+ if (lport == 0 || lport != (lport & 0xffff)) {
fprintf(stderr,
- "traceroute6: port must be >0.\n");
+ "traceroute6: port out of range.\n");
exit(1);
}
+ port = lport & 0xffff;
break;
case 'q':
ep = NULL;