Avoid a NULL pointer derefence introduced in rev. 1.129.
Problem noticed by: bde, gcc(1) Panic caught by: mjacob Patch tested by: mjacob
This commit is contained in:
parent
7d3c25f718
commit
38c1bc358b
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=80211
@ -253,14 +253,14 @@ ip_output(m0, opt, ro, flags, imo)
|
||||
ip->ip_ttl = 1;
|
||||
isbroadcast = in_broadcast(dst->sin_addr, ifp);
|
||||
} else if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr)) &&
|
||||
(imo != NULL) &&
|
||||
(imo->imo_multicast_ifp != NULL)) {
|
||||
imo != NULL && imo->imo_multicast_ifp != NULL) {
|
||||
/*
|
||||
* bypass the normal routing lookup for
|
||||
* multicast packets if the interface is
|
||||
* specified
|
||||
* Bypass the normal routing lookup for multicast
|
||||
* packets if the interface is specified.
|
||||
*/
|
||||
/* No Operation */
|
||||
ifp = imo->imo_multicast_ifp;
|
||||
IFP_TO_IA(ifp, ia);
|
||||
isbroadcast = 0; /* fool gcc */
|
||||
} else {
|
||||
/*
|
||||
* If this is the case, we probably don't want to allocate
|
||||
@ -303,8 +303,6 @@ ip_output(m0, opt, ro, flags, imo)
|
||||
*/
|
||||
if (imo != NULL) {
|
||||
ip->ip_ttl = imo->imo_multicast_ttl;
|
||||
if (imo->imo_multicast_ifp != NULL)
|
||||
ifp = imo->imo_multicast_ifp;
|
||||
if (imo->imo_multicast_vif != -1)
|
||||
ip->ip_src.s_addr =
|
||||
ip_mcast_src(imo->imo_multicast_vif);
|
||||
@ -325,13 +323,9 @@ ip_output(m0, opt, ro, flags, imo)
|
||||
* of outgoing interface.
|
||||
*/
|
||||
if (ip->ip_src.s_addr == INADDR_ANY) {
|
||||
register struct in_ifaddr *ia1;
|
||||
|
||||
TAILQ_FOREACH(ia1, &in_ifaddrhead, ia_link)
|
||||
if (ia1->ia_ifp == ifp) {
|
||||
ip->ip_src = IA_SIN(ia1)->sin_addr;
|
||||
break;
|
||||
}
|
||||
/* Interface may have no addresses. */
|
||||
if (ia != NULL)
|
||||
ip->ip_src = IA_SIN(ia)->sin_addr;
|
||||
}
|
||||
|
||||
IN_LOOKUP_MULTI(ip->ip_dst, ifp, inm);
|
||||
@ -394,15 +388,18 @@ ip_output(m0, opt, ro, flags, imo)
|
||||
* of outgoing interface.
|
||||
*/
|
||||
if (ip->ip_src.s_addr == INADDR_ANY) {
|
||||
ip->ip_src = IA_SIN(ia)->sin_addr;
|
||||
/* Interface may have no addresses. */
|
||||
if (ia != NULL) {
|
||||
ip->ip_src = IA_SIN(ia)->sin_addr;
|
||||
#ifdef IPFIREWALL_FORWARD
|
||||
/* Keep note that we did this - if the firewall changes
|
||||
* the next-hop, our interface may change, changing the
|
||||
* default source IP. It's a shame so much effort happens
|
||||
* twice. Oh well.
|
||||
*/
|
||||
fwd_rewrite_src++;
|
||||
/* Keep note that we did this - if the firewall changes
|
||||
* the next-hop, our interface may change, changing the
|
||||
* default source IP. It's a shame so much effort happens
|
||||
* twice. Oh well.
|
||||
*/
|
||||
fwd_rewrite_src++;
|
||||
#endif /* IPFIREWALL_FORWARD */
|
||||
}
|
||||
}
|
||||
#endif /* notdef */
|
||||
/*
|
||||
@ -824,7 +821,7 @@ ip_output(m0, opt, ro, flags, imo)
|
||||
}
|
||||
|
||||
/* Record statistics for this interface address. */
|
||||
if (!(flags & IP_FORWARDING)) {
|
||||
if (!(flags & IP_FORWARDING) && ia) {
|
||||
ia->ia_ifa.if_opackets++;
|
||||
ia->ia_ifa.if_obytes += m->m_pkthdr.len;
|
||||
}
|
||||
@ -964,7 +961,7 @@ ip_output(m0, opt, ro, flags, imo)
|
||||
/* clean ipsec history once it goes out of the node */
|
||||
ipsec_delaux(m);
|
||||
#endif
|
||||
if (error == 0) {
|
||||
if (error == 0 && ia) {
|
||||
/* Record statistics for this interface address. */
|
||||
ia->ia_ifa.if_opackets++;
|
||||
ia->ia_ifa.if_obytes += m->m_pkthdr.len;
|
||||
|
Loading…
Reference in New Issue
Block a user