Permalink
Browse files

avoid panic on RTM_IFINFO (due to decreased MHLEN).

From: Conny Larsson <conny@verkstad.net>
  • Loading branch information...
1 parent 1b98469 commit 2bb4f5a88b4ac4a89c65fa8d7fdbccbfb61e7e82 itojun committed Feb 6, 2000
Showing with 11 additions and 4 deletions.
  1. +11 −4 freebsd2/sys/net/rtsock.c
@@ -534,9 +534,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:
@@ -551,8 +548,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 2bb4f5a

Please sign in to comment.