Module Name: src Committed By: snj Date: Tue Jan 2 10:39:57 UTC 2018
Modified Files: src/sys/netinet [netbsd-8]: in_l2tp.c src/sys/netinet6 [netbsd-8]: in6_l2tp.c Log Message: Pull up following revision(s) (requested by knakahara in ticket #461): sys/netinet/in_l2tp.c: revision 1.9 sys/netinet6/in6_l2tp.c: revision 1.12 fix mbuf leaks. pointed out and suggested by kre@n.o, thanks. To generate a diff of this commit: cvs rdiff -u -r1.2.8.2 -r1.2.8.3 src/sys/netinet/in_l2tp.c cvs rdiff -u -r1.5.8.2 -r1.5.8.3 src/sys/netinet6/in6_l2tp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/netinet/in_l2tp.c diff -u src/sys/netinet/in_l2tp.c:1.2.8.2 src/sys/netinet/in_l2tp.c:1.2.8.3 --- src/sys/netinet/in_l2tp.c:1.2.8.2 Sun Dec 10 09:41:31 2017 +++ src/sys/netinet/in_l2tp.c Tue Jan 2 10:39:57 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: in_l2tp.c,v 1.2.8.2 2017/12/10 09:41:31 snj Exp $ */ +/* $NetBSD: in_l2tp.c,v 1.2.8.3 2018/01/02 10:39:57 snj Exp $ */ /* * Copyright (c) 2017 Internet Initiative Japan Inc. @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: in_l2tp.c,v 1.2.8.2 2017/12/10 09:41:31 snj Exp $"); +__KERNEL_RCSID(0, "$NetBSD: in_l2tp.c,v 1.2.8.3 2018/01/02 10:39:57 snj Exp $"); #ifdef _KERNEL_OPT #include "opt_l2tp.h" @@ -368,13 +368,11 @@ in_l2tp_match(struct mbuf *m, int off, i KASSERT(proto == IPPROTO_L2TP); - if (m->m_len < off + sizeof(uint32_t)) { - m = m_pullup(m, off + sizeof(uint32_t)); - if (!m) { - /* if payload length < 4 octets */ - return 0; - } - } + /* + * If the packet contains no session ID it cannot match + */ + if (m_length(m) < off + sizeof(uint32_t)) + return 0; /* get L2TP session ID */ m_copydata(m, off, sizeof(uint32_t), (void *)&sess_id); Index: src/sys/netinet6/in6_l2tp.c diff -u src/sys/netinet6/in6_l2tp.c:1.5.8.2 src/sys/netinet6/in6_l2tp.c:1.5.8.3 --- src/sys/netinet6/in6_l2tp.c:1.5.8.2 Sun Dec 10 09:41:32 2017 +++ src/sys/netinet6/in6_l2tp.c Tue Jan 2 10:39:57 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: in6_l2tp.c,v 1.5.8.2 2017/12/10 09:41:32 snj Exp $ */ +/* $NetBSD: in6_l2tp.c,v 1.5.8.3 2018/01/02 10:39:57 snj Exp $ */ /* * Copyright (c) 2017 Internet Initiative Japan Inc. @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: in6_l2tp.c,v 1.5.8.2 2017/12/10 09:41:32 snj Exp $"); +__KERNEL_RCSID(0, "$NetBSD: in6_l2tp.c,v 1.5.8.3 2018/01/02 10:39:57 snj Exp $"); #ifdef _KERNEL_OPT #include "opt_l2tp.h" @@ -360,13 +360,11 @@ in6_l2tp_match(struct mbuf *m, int off, KASSERT(proto == IPPROTO_L2TP); - if (m->m_len < off + sizeof(uint32_t)) { - m = m_pullup(m, off + sizeof(uint32_t)); - if (!m) { - /* if payload length < 4 octets */ - return 0; - } - } + /* + * If the packet contains no session ID it cannot match + */ + if (m_length(m) < off + sizeof(uint32_t)) + return 0; /* get L2TP session ID */ m_copydata(m, off, sizeof(uint32_t), (void *)&sess_id);