Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/netinet Fix null deref, m could be NULL if M_PREPEND fails.
details: https://anonhg.NetBSD.org/src/rev/64d9e934aee0
branches: trunk
changeset: 829210:64d9e934aee0
user: maxv <maxv%NetBSD.org@localhost>
date: Mon Jan 22 09:51:06 2018 +0000
description:
Fix null deref, m could be NULL if M_PREPEND fails.
diffstat:
sys/netinet/in_l2tp.c | 13 ++++++++-----
1 files changed, 8 insertions(+), 5 deletions(-)
diffs (36 lines):
diff -r 757223fa3876 -r 64d9e934aee0 sys/netinet/in_l2tp.c
--- a/sys/netinet/in_l2tp.c Mon Jan 22 09:45:32 2018 +0000
+++ b/sys/netinet/in_l2tp.c Mon Jan 22 09:51:06 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: in_l2tp.c,v 1.9 2017/12/18 03:21:44 knakahara Exp $ */
+/* $NetBSD: in_l2tp.c,v 1.10 2018/01/22 09:51:06 maxv 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.9 2017/12/18 03:21:44 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in_l2tp.c,v 1.10 2018/01/22 09:51:06 maxv Exp $");
#ifdef _KERNEL_OPT
#include "opt_l2tp.h"
@@ -196,11 +196,14 @@
/* prepend new IP header */
M_PREPEND(m, sizeof(struct ip), M_DONTWAIT);
+ if (m == NULL) {
+ error = ENOBUFS;
+ goto out;
+ }
if (IP_HDR_ALIGNED_P(mtod(m, void *)) == 0) {
- if (m)
- m = m_copyup(m, sizeof(struct ip), 0);
+ m = m_copyup(m, sizeof(struct ip), 0);
} else {
- if (m && m->m_len < sizeof(struct ip))
+ if (m->m_len < sizeof(struct ip))
m = m_pullup(m, sizeof(struct ip));
}
if (m == NULL) {
Home |
Main Index |
Thread Index |
Old Index