summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authormpi <>2014-02-07 09:50:04 +0000
committermpi <>2014-02-07 09:50:04 +0000
commitb8bea5619a937cbf3e13730062804bfa8ddf5e7b (patch)
tree9eaee409814c9f60e7dd1ec147e5e3c338cfb0d5 /src/lib
parentf4838ba0cb63eb803af7bf3ba48564dc877b116e (diff)
downloadopenbsd-b8bea5619a937cbf3e13730062804bfa8ddf5e7b.tar.gz
openbsd-b8bea5619a937cbf3e13730062804bfa8ddf5e7b.tar.bz2
openbsd-b8bea5619a937cbf3e13730062804bfa8ddf5e7b.zip
Fix inet6_opt_init() to only check extlen when extbuff is not NULL
as per RFC 3542, from DragonFlyBSD via Eitan Adler. ok bluhm@
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libc/net/ip6opt.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/src/lib/libc/net/ip6opt.c b/src/lib/libc/net/ip6opt.c
index b215f9ac3e..c3609621c2 100644
--- a/src/lib/libc/net/ip6opt.c
+++ b/src/lib/libc/net/ip6opt.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ip6opt.c,v 1.4 2006/12/09 01:12:28 itojun Exp $ */ 1/* $OpenBSD: ip6opt.c,v 1.5 2014/02/07 09:50:04 mpi Exp $ */
2/* $KAME: ip6opt.c,v 1.18 2005/06/15 07:11:35 keiichi Exp $ */ 2/* $KAME: ip6opt.c,v 1.18 2005/06/15 07:11:35 keiichi Exp $ */
3 3
4/* 4/*
@@ -383,11 +383,8 @@ inet6_opt_init(void *extbuf, socklen_t extlen)
383{ 383{
384 struct ip6_ext *ext = (struct ip6_ext *)extbuf; 384 struct ip6_ext *ext = (struct ip6_ext *)extbuf;
385 385
386 if (extlen < 0 || (extlen % 8))
387 return (-1);
388
389 if (ext) { 386 if (ext) {
390 if (extlen == 0) 387 if (extlen <= 0 || (extlen % 8))
391 return (-1); 388 return (-1);
392 ext->ip6e_len = (extlen >> 3) - 1; 389 ext->ip6e_len = (extlen >> 3) - 1;
393 } 390 }