Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys fix mbuf leaks. pointed out and suggested by kre@n.o, th...



details:   https://anonhg.NetBSD.org/src/rev/ef2d7c259423
branches:  trunk
changeset: 828522:ef2d7c259423
user:      knakahara <knakahara%NetBSD.org@localhost>
date:      Mon Dec 18 03:21:44 2017 +0000

description:
fix mbuf leaks. pointed out and suggested by kre@n.o, thanks.

diffstat:

 sys/netinet/in_l2tp.c   |  16 +++++++---------
 sys/netinet6/in6_l2tp.c |  16 +++++++---------
 2 files changed, 14 insertions(+), 18 deletions(-)

diffs (74 lines):

diff -r 57fb263ce2d5 -r ef2d7c259423 sys/netinet/in_l2tp.c
--- a/sys/netinet/in_l2tp.c     Mon Dec 18 03:20:12 2017 +0000
+++ b/sys/netinet/in_l2tp.c     Mon Dec 18 03:21:44 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: in_l2tp.c,v 1.8 2017/12/18 03:20:12 knakahara Exp $    */
+/*     $NetBSD: in_l2tp.c,v 1.9 2017/12/18 03:21:44 knakahara 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.8 2017/12/18 03:20:12 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in_l2tp.c,v 1.9 2017/12/18 03:21:44 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_l2tp.h"
@@ -368,13 +368,11 @@
 
        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);
diff -r 57fb263ce2d5 -r ef2d7c259423 sys/netinet6/in6_l2tp.c
--- a/sys/netinet6/in6_l2tp.c   Mon Dec 18 03:20:12 2017 +0000
+++ b/sys/netinet6/in6_l2tp.c   Mon Dec 18 03:21:44 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: in6_l2tp.c,v 1.11 2017/12/18 03:20:13 knakahara Exp $  */
+/*     $NetBSD: in6_l2tp.c,v 1.12 2017/12/18 03:21:44 knakahara 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.11 2017/12/18 03:20:13 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6_l2tp.c,v 1.12 2017/12/18 03:21:44 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_l2tp.h"
@@ -360,13 +360,11 @@
 
        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);



Home | Main Index | Thread Index | Old Index