Fixes for various nits found by the Coverity tool.

In particular 2 missed return values and an inappropriate bcopy from
a possibly NULL pointer.

Reviewed by:	jake
Approved by:	rwatson
MFC after:	1 week
This commit is contained in:
George V. Neville-Neil 2005-05-15 02:28:30 +00:00
parent 1771f872d5
commit 403cbcf59f
4 changed files with 8 additions and 5 deletions

View File

@ -2092,13 +2092,16 @@ icmp6_reflect(m, off)
sa6_src.sin6_len = sizeof(sa6_src);
sa6_src.sin6_addr = ip6->ip6_dst;
in6_recoverscope(&sa6_src, &ip6->ip6_dst, m->m_pkthdr.rcvif);
in6_embedscope(&ip6->ip6_dst, &sa6_src, NULL, NULL);
if (in6_embedscope(&ip6->ip6_dst, &sa6_src, NULL, NULL))
goto bad;
bzero(&sa6_dst, sizeof(sa6_dst));
sa6_dst.sin6_family = AF_INET6;
sa6_dst.sin6_len = sizeof(sa6_dst);
sa6_dst.sin6_addr = t;
in6_recoverscope(&sa6_dst, &t, m->m_pkthdr.rcvif);
in6_embedscope(&t, &sa6_dst, NULL, NULL);
if (in6_embedscope(&t, &sa6_dst, NULL, NULL))
goto bad;
#ifdef COMPAT_RFC1885
/*

View File

@ -667,7 +667,7 @@ in6_selectroute(dstsock, opts, mopts, ro, retifp, retrt, clone)
* (this may happen when we are sending a packet to one of
* our own addresses.)
*/
if (opts && opts->ip6po_pktinfo &&
if (ifp && opts && opts->ip6po_pktinfo &&
opts->ip6po_pktinfo->ipi6_ifindex) {
if (!(ifp->if_flags & IFF_LOOPBACK) &&
ifp->if_index !=

View File

@ -769,7 +769,7 @@ ip6_fw_chk(struct ip6_hdr **pip6,
* - The packet is not an ICMP packet, or is an ICMP query packet
* - The packet is not a multicast or broadcast packet
*/
if ((rule->fw_flg & IPV6_FW_F_COMMAND) == IPV6_FW_F_REJECT
if (rule && (rule->fw_flg & IPV6_FW_F_COMMAND) == IPV6_FW_F_REJECT
&& (nxt != IPPROTO_ICMPV6 || is_icmp6_query(ip6, off))
&& !((*m)->m_flags & (M_BCAST|M_MCAST))
&& !IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst)) {

View File

@ -2603,7 +2603,7 @@ ip6_copypktopts(src, canwait)
if (src->ip6po_nexthop) {
dst->ip6po_nexthop = malloc(src->ip6po_nexthop->sa_len,
M_IP6OPT, canwait);
if (dst->ip6po_nexthop == NULL && canwait == M_NOWAIT)
if (dst->ip6po_nexthop == NULL)
goto bad;
bcopy(src->ip6po_nexthop, dst->ip6po_nexthop,
src->ip6po_nexthop->sa_len);