Permalink
Browse files

avoid panic on RTM_IFINFO (due to decreased MHLEN).

From: Conny Larsson <conny@verkstad.net>

NOTE: bsdi[34] have already fixed the problem - too bad it wasn't backported
to others.
NOTE: if i'm not mistaken, freebsd4.0 looks needs this fix as well
due to addition of m->m_pkthdr.header.
  • Loading branch information...
1 parent 704bca6 commit c7823813058fcf254d8b32e004aae4aed35b949b itojun committed Feb 6, 2000
Showing with 22 additions and 8 deletions.
  1. +11 −4 freebsd3/sys/net/rtsock.c
  2. +11 −4 openbsd/sys/net/rtsock.c
View
@@ -698,9 +698,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:
@@ -720,8 +717,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 *);
View
@@ -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 *);

0 comments on commit c782381

Please sign in to comment.