summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2000-02-07 06:08:05 +0000
committerJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2000-02-07 06:08:05 +0000
commit4c56a47e2e8f387dc8a601f300b672b1619113f8 (patch)
tree3b50a0b79505f78a0d7bb404c9711f9e2c07c7b7 /sys
parent449cfd223309afe74d6c4a8c341a74fbd9a011c2 (diff)
make more check about mbuf len before rolling message for routing header.
Diffstat (limited to 'sys')
-rw-r--r--sys/net/rtsock.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c
index 57303703912..6df1c2b2613 100644
--- a/sys/net/rtsock.c
+++ b/sys/net/rtsock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtsock.c,v 1.8 1999/12/08 06:50:18 itojun Exp $ */
+/* $OpenBSD: rtsock.c,v 1.9 2000/02/07 06:08:04 itojun Exp $ */
/* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */
/*
@@ -593,9 +593,6 @@ rt_msg1(type, rtinfo)
register struct sockaddr *sa;
int len, dlen;
- m = m_gethdr(M_DONTWAIT, MT_DATA);
- if (m == 0)
- return (m);
switch (type) {
case RTM_DELADDR:
@@ -610,8 +607,18 @@ rt_msg1(type, rtinfo)
default:
len = sizeof(struct rt_msghdr);
}
- if (len > MHLEN)
+ if (len > MCLBYTES)
panic("rt_msg1");
+ m = m_gethdr(M_DONTWAIT, MT_DATA);
+ if (m && len > MHLEN) {
+ MCLGET(m, M_DONTWAIT);
+ if ((m->m_flags & M_EXT) == 0) {
+ m_free(m);
+ m = NULL;
+ }
+ }
+ if (m == 0)
+ return (m);
m->m_pkthdr.len = m->m_len = len;
m->m_pkthdr.rcvif = 0;
rtm = mtod(m, struct rt_msghdr *);