Source-Changes-HG archive

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

src: Replace KASSERTMSG by a real check. L2 encapsulation protoc...



details:   https://anonhg.NetBSD.org/src/rev/6ee3b569ec55
branches:  trunk
changeset: 317972:6ee3b569ec55
user:      maxv <maxv%NetBSD.org@localhost>
date:      Mon Apr 09 16:14:11 2018 +0000
description:
Replace KASSERTMSG by a real check. L2 encapsulation protocols (at least
L2TP) don't ensure the LLC is there, and in !DIAGNOSTIC configurations
m_copydata will crash. Tested with L2TP.

diffstat:

 sys/net/if_ethersubr.c |  10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diffs (31 lines):

diff -r cc4a9b880116 -r 6ee3b569ec55 sys/net/if_ethersubr.c
--- a/sys/net/if_ethersubr.c    Mon Apr 09 15:45:16 2018 +0000
+++ b/sys/net/if_ethersubr.c    Mon Apr 09 16:14:11 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_ethersubr.c,v 1.262 2018/04/09 11:35:22 maxv Exp $  */
+/*     $NetBSD: if_ethersubr.c,v 1.263 2018/04/09 16:14:11 maxv Exp $  */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.262 2018/04/09 11:35:22 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.263 2018/04/09 16:14:11 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -759,8 +759,10 @@
        case ETHERTYPE_SLOWPROTOCOLS: {
                uint8_t subtype;
 
-               KASSERTMSG((m->m_pkthdr.len >= sizeof(*eh) + sizeof(subtype)),
-                   "too short slow protocol packet");
+               if (m->m_pkthdr.len < sizeof(*eh) + sizeof(subtype)) {
+                       m_freem(m);
+                       return;
+               }
 
                m_copydata(m, sizeof(*eh), sizeof(subtype), &subtype);
                switch (subtype) {



Home | Main Index | Thread Index | Old Index