changeset 12608:708c1594201d

6959210 libtopo: xml parsing incorrect for range elements that specify subset of range 6942779 libtopo: error path in topo_xml_walk() can corrupt internal linked list of topo ranges
author Robert Johnston <Robert.Johnston@Sun.COM>
date Thu, 10 Jun 2010 18:47:15 -0700
parents 2bc0f474d551
children 2e69f035b60b
files usr/src/lib/fm/topo/libtopo/common/topo_xml.c
diffstat 1 files changed, 15 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/lib/fm/topo/libtopo/common/topo_xml.c	Thu Jun 10 18:27:18 2010 -0700
+++ b/usr/src/lib/fm/topo/libtopo/common/topo_xml.c	Thu Jun 10 18:47:15 2010 -0700
@@ -20,8 +20,7 @@
  */
 
 /*
- * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
  */
 
 #include <libxml/parser.h>
@@ -1177,7 +1176,7 @@
 	int pgcnt = 0;
 	int dcnt = 0;
 	int ecnt = 0;
-	int joined_set = 0;
+	int joined_set = 0, inst;
 	xmlChar *set;
 	char *key;
 
@@ -1323,8 +1322,12 @@
 				    rd->rd_name) != 0)
 					continue;
 
+				inst = topo_node_instance(ct);
+				if (inst < rd->rd_min || inst > rd->rd_max)
+					continue;
+
 				if (fac_enum_process(mp, target, ct) < 0)
-						return (-1);
+					return (-1);
 
 				if (fac_process(mp, target, rd, ct) < 0)
 					return (-1);
@@ -1890,14 +1893,15 @@
 				    troot)) == NULL) {
 					topo_dprintf(mp->tm_hdl, TOPO_DBG_XML,
 					    "topo_xml_walk: failed1\n");
+				} else {
+					if (pr == NULL) {
+						rr = pr = rdp;
+					} else {
+						pr->rd_next = rdp;
+						pr = rdp;
+					}
+					rr->rd_cnt++;
 				}
-				if (pr == NULL) {
-					rr = pr = rdp;
-				} else {
-					pr->rd_next = rdp;
-					pr = rdp;
-				}
-				rr->rd_cnt++;
 			}
 			xmlFree(set);
 		}