Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys ar_tha() can return NULL; treat this as an error.



details:   https://anonhg.NetBSD.org/src/rev/ce4bc05eb69f
branches:  trunk
changeset: 749165:ce4bc05eb69f
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Nov 20 02:14:56 2009 +0000

description:
ar_tha() can return NULL; treat this as an error.

diffstat:

 sys/net/if_arcsubr.c   |  12 ++++++++----
 sys/net/if_ecosubr.c   |   7 ++++---
 sys/net/if_ethersubr.c |   9 ++++++---
 sys/net/if_fddisubr.c  |   8 ++++----
 sys/net/if_tokensubr.c |  12 ++++++------
 sys/netinet/if_arp.c   |  10 ++++++----
 6 files changed, 34 insertions(+), 24 deletions(-)

diffs (191 lines):

diff -r fdb836b4654a -r ce4bc05eb69f sys/net/if_arcsubr.c
--- a/sys/net/if_arcsubr.c      Thu Nov 19 22:27:26 2009 +0000
+++ b/sys/net/if_arcsubr.c      Fri Nov 20 02:14:56 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_arcsubr.c,v 1.60 2008/11/07 00:20:13 dyoung Exp $   */
+/*     $NetBSD: if_arcsubr.c,v 1.61 2009/11/20 02:14:56 christos Exp $ */
 
 /*
  * Copyright (c) 1994, 1995 Ignatios Souvatzis
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_arcsubr.c,v 1.60 2008/11/07 00:20:13 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_arcsubr.c,v 1.61 2009/11/20 02:14:56 christos Exp $");
 
 #include "opt_inet.h"
 
@@ -197,8 +197,12 @@
                arph = mtod(m, struct arphdr *);
                if (m->m_flags & M_BCAST)
                        adst = arcbroadcastaddr;
-               else
-                       adst = *ar_tha(arph);
+               else {
+                       uint8_t *tha = ar_tha(arph);
+                       if (tha == NULL)
+                               return 0;
+                       adst = *tha;
+               }
 
                arph->ar_hrd = htons(ARPHRD_ARCNET);
 
diff -r fdb836b4654a -r ce4bc05eb69f sys/net/if_ecosubr.c
--- a/sys/net/if_ecosubr.c      Thu Nov 19 22:27:26 2009 +0000
+++ b/sys/net/if_ecosubr.c      Fri Nov 20 02:14:56 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_ecosubr.c,v 1.32 2009/03/18 16:00:22 cegger Exp $   */
+/*     $NetBSD: if_ecosubr.c,v 1.33 2009/11/20 02:14:56 christos Exp $ */
 
 /*-
  * Copyright (c) 2001 Ben Harris
@@ -58,7 +58,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ecosubr.c,v 1.32 2009/03/18 16:00:22 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ecosubr.c,v 1.33 2009/11/20 02:14:56 christos Exp $");
 
 #include "bpfilter.h"
 #include "opt_inet.h"
@@ -265,7 +265,8 @@
                            ECO_ADDR_LEN);
                else {
                        tha = ar_tha(ah);
-                       KASSERT(tha != NULL);
+                       if (tha == NULL)
+                               return 0;
                        memcpy(ehdr.eco_dhost, tha, ECO_ADDR_LEN);
                }
 
diff -r fdb836b4654a -r ce4bc05eb69f sys/net/if_ethersubr.c
--- a/sys/net/if_ethersubr.c    Thu Nov 19 22:27:26 2009 +0000
+++ b/sys/net/if_ethersubr.c    Fri Nov 20 02:14:56 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_ethersubr.c,v 1.172 2009/05/29 04:57:04 darran Exp $        */
+/*     $NetBSD: if_ethersubr.c,v 1.173 2009/11/20 02:14:56 christos Exp $      */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.172 2009/05/29 04:57:04 darran Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.173 2009/11/20 02:14:56 christos Exp $");
 
 #include "opt_inet.h"
 #include "opt_atalk.h"
@@ -301,7 +301,10 @@
                else {
                        void *tha = ar_tha(ah);
 
-                       KASSERT(tha);
+                       if (tha == NULL) {
+                               /* fake with ARPHDR_IEEE1394 */
+                               return 0;
+                       }
                        memcpy(edst, tha, sizeof(edst));
                }
 
diff -r fdb836b4654a -r ce4bc05eb69f sys/net/if_fddisubr.c
--- a/sys/net/if_fddisubr.c     Thu Nov 19 22:27:26 2009 +0000
+++ b/sys/net/if_fddisubr.c     Fri Nov 20 02:14:56 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_fddisubr.c,v 1.77 2008/11/07 00:20:13 dyoung Exp $  */
+/*     $NetBSD: if_fddisubr.c,v 1.78 2009/11/20 02:14:56 christos Exp $        */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -96,7 +96,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_fddisubr.c,v 1.77 2008/11/07 00:20:13 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_fddisubr.c,v 1.78 2009/11/20 02:14:56 christos Exp $");
 
 #include "opt_inet.h"
 #include "opt_atalk.h"
@@ -306,8 +306,8 @@
                        memcpy(edst, etherbroadcastaddr, sizeof(edst));
                else {
                        void *tha = ar_tha(ah);
-
-                       KASSERT(tha);
+                       if (tha == NULL)
+                               return 0;
                        memcpy(edst, tha, sizeof(edst));
                }
 
diff -r fdb836b4654a -r ce4bc05eb69f sys/net/if_tokensubr.c
--- a/sys/net/if_tokensubr.c    Thu Nov 19 22:27:26 2009 +0000
+++ b/sys/net/if_tokensubr.c    Fri Nov 20 02:14:56 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_tokensubr.c,v 1.57 2009/04/18 14:58:05 tsutsui Exp $        */
+/*     $NetBSD: if_tokensubr.c,v 1.58 2009/11/20 02:14:57 christos Exp $       */
 
 /*
  * Copyright (c) 1982, 1989, 1993
@@ -92,7 +92,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_tokensubr.c,v 1.57 2009/04/18 14:58:05 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_tokensubr.c,v 1.58 2009/11/20 02:14:57 christos Exp $");
 
 #include "opt_inet.h"
 #include "opt_atalk.h"
@@ -308,10 +308,10 @@
                        memcpy(edst, tokenbroadcastaddr, sizeof(edst));
                }
                else {
-                       void *tha = (void *)ar_tha(ah);
-                       KASSERT(tha);
-                       if (tha)
-                               memcpy((void *)edst, tha, sizeof(edst));
+                       void *tha = ar_tha(ah);
+                       if (tha == NULL)
+                               return 0;
+                       memcpy(edst, tha, sizeof(edst));
                        trh = (struct token_header *)M_TRHSTART(m);
                        trh->token_ac = TOKEN_AC;
                        trh->token_fc = TOKEN_FC;
diff -r fdb836b4654a -r ce4bc05eb69f sys/netinet/if_arp.c
--- a/sys/netinet/if_arp.c      Thu Nov 19 22:27:26 2009 +0000
+++ b/sys/netinet/if_arp.c      Fri Nov 20 02:14:56 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_arp.c,v 1.148 2009/11/03 00:57:42 christos Exp $    */
+/*     $NetBSD: if_arp.c,v 1.149 2009/11/20 02:14:57 christos Exp $    */
 
 /*-
  * Copyright (c) 1998, 2000, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.148 2009/11/03 00:57:42 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.149 2009/11/20 02:14:57 christos Exp $");
 
 #include "opt_ddb.h"
 #include "opt_inet.h"
@@ -1403,7 +1403,8 @@
        if (myip_initialized)
                goto wake;
        tha = ar_tha(ah);
-       KASSERT(tha);
+       if (tha == NULL)
+               goto out;
        if (memcmp(tha, CLLADDR(ifp->if_sadl), ifp->if_sadl->sdl_alen))
                goto out;
        memcpy(&srv_ip, ar_spa(ah), sizeof(srv_ip));
@@ -1444,7 +1445,8 @@
 
        memcpy(ar_sha(ah), CLLADDR(ifp->if_sadl), ah->ar_hln);
        tha = ar_tha(ah);
-       KASSERT(tha);
+       if (tha == NULL)
+               return;
        memcpy(tha, CLLADDR(ifp->if_sadl), ah->ar_hln);
 
        sa.sa_family = AF_ARP;



Home | Main Index | Thread Index | Old Index