diff options
author | Jun-ichiro itojun Hagino <itojun@cvs.openbsd.org> | 2000-10-12 14:13:11 +0000 |
---|---|---|
committer | Jun-ichiro itojun Hagino <itojun@cvs.openbsd.org> | 2000-10-12 14:13:11 +0000 |
commit | 017586894651eba06eb435b5778575d169225b55 (patch) | |
tree | e0c7cab156180749eb6a7889eb337d05aa391486 /sbin/ping6 | |
parent | d5d69f30b41e162691a948e37c2d1babe721087d (diff) |
don't segv on too many arguments. sync with kame
Diffstat (limited to 'sbin/ping6')
-rw-r--r-- | sbin/ping6/ping6.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/sbin/ping6/ping6.c b/sbin/ping6/ping6.c index 0562db07dec..3f737e334c8 100644 --- a/sbin/ping6/ping6.c +++ b/sbin/ping6/ping6.c @@ -1,5 +1,5 @@ -/* $OpenBSD: ping6.c,v 1.14 2000/10/12 09:02:19 itojun Exp $ */ -/* $KAME: ping6.c,v 1.92 2000/10/11 00:04:47 itojun Exp $ */ +/* $OpenBSD: ping6.c,v 1.15 2000/10/12 14:13:10 itojun Exp $ */ +/* $KAME: ping6.c,v 1.93 2000/10/12 10:27:00 itojun Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -299,6 +299,7 @@ main(argc, argv) char *policy_out = NULL; #endif double intval; + size_t rthlen; /* just to be sure */ memset(&smsghdr, 0, sizeof(&smsghdr)); @@ -511,11 +512,16 @@ main(argc, argv) if (argc > 1) { #ifdef IPV6_RECVRTHDR /* 2292bis */ - ip6optlen += CMSG_SPACE(inet6_rth_space(IPV6_RTHDR_TYPE_0, + rthlen = CMSG_SPACE(inet6_rth_space(IPV6_RTHDR_TYPE_0, argc - 1)); #else /* RFC2292 */ - ip6optlen += inet6_rthdr_space(IPV6_RTHDR_TYPE_0, argc - 1); + rthlen = inet6_rthdr_space(IPV6_RTHDR_TYPE_0, argc - 1); #endif + if (rthlen == 0) { + errx(1, "too many intermediate hops"); + /*NOTREACHED*/ + } + ip6optlen += rthlen; } if (options & F_NIGROUP) { |