diff options
author | 1997-08-04 01:12:06 +0000 | |
---|---|---|
committer | 1997-08-04 01:12:06 +0000 | |
commit | 51caddc8b281cf7f09fa5fe99bd342578b376519 (patch) | |
tree | 1683b2235c549a8f044afefedfbd59874edc6368 | |
parent | mips needs -call_shared to as for asm code (diff) | |
download | wireguard-openbsd-51caddc8b281cf7f09fa5fe99bd342578b376519.tar.xz wireguard-openbsd-51caddc8b281cf7f09fa5fe99bd342578b376519.zip |
No more crashes because of this bug (double m_freem(), essentially).
-rw-r--r-- | sys/netinet/ip_output.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c index a3d34a4d54e..e780feb7efc 100644 --- a/sys/netinet/ip_output.c +++ b/sys/netinet/ip_output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_output.c,v 1.20 1997/07/31 00:40:21 deraadt Exp $ */ +/* $OpenBSD: ip_output.c,v 1.21 1997/08/04 01:12:06 angelos Exp $ */ /* $NetBSD: ip_output.c,v 1.28 1996/02/13 23:43:07 christos Exp $ */ /* @@ -164,20 +164,28 @@ ip_output(m0, va_alist) dst->sen_ip_dst = ip->ip_dst; dst->sen_proto = ip->ip_p; - if (m->m_len < hlen + 2 * sizeof(u_int16_t)) { - if ((m = m_pullup(m, hlen + 2 * sizeof(u_int16_t))) == 0) - goto bad; - ip = mtod(m, struct ip *); - } - switch (ip->ip_p) { case IPPROTO_UDP: + if (m->m_len < hlen + 2 * sizeof(u_int16_t)) { + if ((m = m_pullup(m, hlen + 2 * + sizeof(u_int16_t))) == 0) + return ENOBUFS; + ip = mtod(m, struct ip *); + } + udp = (struct udphdr *) (mtod(m, u_char *) + hlen); dst->sen_sport = ntohs(udp->uh_sport); dst->sen_dport = ntohs(udp->uh_dport); break; case IPPROTO_TCP: + if (m->m_len < hlen + 2 * sizeof(u_int16_t)) { + if ((m = m_pullup(m, hlen + 2 * + sizeof(u_int16_t))) == 0) + return ENOBUFS; + ip = mtod(m, struct ip *); + } + tcp = (struct tcphdr *) (mtod(m, u_char *) + hlen); dst->sen_sport = ntohs(tcp->th_sport); dst->sen_dport = ntohs(tcp->th_dport); |