check for null mbuf ptr before freeing (4.3BSD/sys/{130,131,133})
[unix-history] / usr / src / sys / netinet / ip_output.c
index c81eef4..0e18353 100644 (file)
@@ -3,7 +3,7 @@
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
- *     @(#)ip_output.c 7.4 (Berkeley) %G%
+ *     @(#)ip_output.c 7.6 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -102,7 +102,10 @@ ip_output(m, opt, ro, flags)
                if (ro->ro_rt == 0)
                        rtalloc(ro);
                if (ro->ro_rt == 0 || (ifp = ro->ro_rt->rt_ifp) == 0) {
                if (ro->ro_rt == 0)
                        rtalloc(ro);
                if (ro->ro_rt == 0 || (ifp = ro->ro_rt->rt_ifp) == 0) {
-                       error = ENETUNREACH;
+                       if (in_localaddr(ip->ip_dst))
+                               error = EHOSTUNREACH;
+                       else
+                               error = ENETUNREACH;
                        goto bad;
                }
                ro->ro_rt->rt_use++;
                        goto bad;
                }
                ro->ro_rt->rt_use++;
@@ -347,7 +350,7 @@ ip_ctloutput(op, so, level, optname, m)
                }
                break;
        }
                }
                break;
        }
-       if (op == PRCO_SETOPT)
+       if (op == PRCO_SETOPT && *m)
                (void)m_free(*m);
        return (error);
 }
                (void)m_free(*m);
        return (error);
 }