Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/ic Add some defensive code to the unsolicited event ...



details:   https://anonhg.NetBSD.org/src/rev/f4b201285d91
branches:  trunk
changeset: 479866:f4b201285d91
user:      matt <matt%NetBSD.org@localhost>
date:      Thu Dec 23 18:14:59 1999 +0000

description:
Add some defensive code to the unsolicited event printing

diffstat:

 sys/dev/ic/pdq.c    |  28 ++++++++++++++++++++++++----
 sys/dev/ic/pdqreg.h |  14 +++++++++-----
 2 files changed, 33 insertions(+), 9 deletions(-)

diffs (98 lines):

diff -r c68e3c40151f -r f4b201285d91 sys/dev/ic/pdq.c
--- a/sys/dev/ic/pdq.c  Thu Dec 23 17:24:30 1999 +0000
+++ b/sys/dev/ic/pdq.c  Thu Dec 23 18:14:59 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pdq.c,v 1.26 1999/09/19 22:58:31 matt Exp $    */
+/*     $NetBSD: pdq.c,v 1.27 1999/12/23 18:14:59 matt Exp $    */
 
 /*-
  * Copyright (c) 1995,1996 Matt Thomas <matt%3am-software.com@localhost>
@@ -653,20 +653,40 @@
     pdq_unsolicited_info_t *ui = &pdq->pdq_unsolicited_info;
     volatile const pdq_consumer_block_t *cbp = pdq->pdq_cbp;
     pdq_descriptor_block_t *dbp = pdq->pdq_dbp;
-    const pdq_unsolicited_event_t *event;
-    pdq_rxdesc_t *rxd;
 
     /*
      * Process each unsolicited event (if any).
      */
 
     while (cbp->pdqcb_unsolicited_event != ui->ui_completion) {
-       rxd = &dbp->pdqdb_unsolicited_events[ui->ui_completion];
+       const pdq_unsolicited_event_t *event;
        event = &ui->ui_events[ui->ui_completion & (PDQ_NUM_UNSOLICITED_EVENTS-1)];
        PDQ_OS_UNSOL_EVENT_POSTSYNC(pdq, event);
 
        switch (event->event_type) {
            case PDQ_UNSOLICITED_EVENT: {
+               int bad_event = 0;
+               switch (event->event_entity) {
+                   case PDQ_ENTITY_STATION: {
+                       bad_event = event->event_code.value >= PDQ_STATION_EVENT_MAX;
+                       break;
+                   }
+                   case PDQ_ENTITY_LINK: {
+                       bad_event = event->event_code.value >= PDQ_LINK_EVENT_MAX;
+                       break;
+                   }
+                   case PDQ_ENTITY_PHY_PORT: {
+                       bad_event = event->event_code.value >= PDQ_PHY_EVENT_MAX;
+                       break;
+                   }
+                   default: {
+                       bad_event = 1;
+                       break;
+                   }
+               }
+               if (bad_event) {
+                   break;
+               }
                printf(PDQ_OS_PREFIX "Unsolicited Event: %s: %s",
                       PDQ_OS_PREFIX_ARGS,
                       pdq_entities[event->event_entity],
diff -r c68e3c40151f -r f4b201285d91 sys/dev/ic/pdqreg.h
--- a/sys/dev/ic/pdqreg.h       Thu Dec 23 17:24:30 1999 +0000
+++ b/sys/dev/ic/pdqreg.h       Thu Dec 23 18:14:59 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pdqreg.h,v 1.12 1998/05/27 14:01:02 matt Exp $ */
+/*     $NetBSD: pdqreg.h,v 1.13 1999/12/23 18:14:59 matt Exp $ */
 
 /*-
  * Copyright (c) 1995, 1996 Matt Thomas <matt%3am-software.com@localhost>
@@ -1061,11 +1061,13 @@
 typedef enum {
     PDQ_ENTITY_STATION=0,
     PDQ_ENTITY_LINK=1,
-    PDQ_ENTITY_PHY_PORT=2
+    PDQ_ENTITY_PHY_PORT=2,
+    PDQ_ENTITY_MAX=3
 } pdq_entity_t;
 
 typedef enum {
-    PDQ_STATION_EVENT_TRACE_RECEIVED=1
+    PDQ_STATION_EVENT_TRACE_RECEIVED=1,
+    PDQ_STATION_EVENT_MAX=2
 } pdq_station_event_t;
 
 typedef enum {
@@ -1089,7 +1091,8 @@
     PDQ_LINK_EVENT_RING_PURGE_ERROR=15,
     PDQ_LINK_EVENT_FCI_STRIP_ERROR=16,
     PDQ_LINK_EVENT_TRACE_INITIATED=17,
-    PDQ_LINK_EVENT_DIRECTED_BEACON_RECEIVED=18
+    PDQ_LINK_EVENT_DIRECTED_BEACON_RECEIVED=18,
+    PDQ_LINK_EVENT_MAX=19
 } pdq_link_event_t;
 
 typedef enum {
@@ -1103,7 +1106,8 @@
 typedef enum {
     PDQ_PHY_EVENT_LEM_ERROR_MONITOR_REJECT=0,
     PDQ_PHY_EVENT_ELASTICITY_BUFFER_ERROR=1,
-    PDQ_PHY_EVENT_LINK_CONFIDENCE_TEST_REJECT=2
+    PDQ_PHY_EVENT_LINK_CONFIDENCE_TEST_REJECT=2,
+    PDQ_PHY_EVENT_MAX=3
 } pdq_phy_event_t;
 
 typedef enum {



Home | Main Index | Thread Index | Old Index