Source-Changes-HG archive

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

[src/trunk]: src/sys/net wg: Assert MCLBYTES is enough for requested length i...



details:   https://anonhg.NetBSD.org/src/rev/a2f1b17aa590
branches:  trunk
changeset: 943132:a2f1b17aa590
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Thu Aug 27 13:44:41 2020 +0000

description:
wg: Assert MCLBYTES is enough for requested length in wg_get_mbuf.

diffstat:

 sys/net/if_wg.c |  7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diffs (28 lines):

diff -r 920d91272198 -r a2f1b17aa590 sys/net/if_wg.c
--- a/sys/net/if_wg.c   Thu Aug 27 10:10:23 2020 +0000
+++ b/sys/net/if_wg.c   Thu Aug 27 13:44:41 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_wg.c,v 1.29 2020/08/27 03:05:34 riastradh Exp $     */
+/*     $NetBSD: if_wg.c,v 1.30 2020/08/27 13:44:41 riastradh Exp $     */
 
 /*
  * Copyright (C) Ryota Ozaki <ozaki.ryota%gmail.com@localhost>
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.29 2020/08/27 03:05:34 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.30 2020/08/27 13:44:41 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -3637,6 +3637,9 @@
 {
        struct mbuf *m;
 
+       KASSERT(leading_len <= MCLBYTES);
+       KASSERT(len <= MCLBYTES - leading_len);
+
        m = m_gethdr(M_DONTWAIT, MT_DATA);
        if (m == NULL)
                return NULL;



Home | Main Index | Thread Index | Old Index