git: 9front

Download patch

ref: 750be7009dbc3e0573c1adaf54e14189f2ca49c4
parent: 63f6121f8b6ff4b3e47bff2d02b4cc1a4331f071
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Tue Mar 24 23:03:24 EDT 2015

zynq: fix out of bounds access in etherprobe()

calling etherprobe() with -1 cardno will rereference
and call cards[-1].reset() which is wrong. don't do that!

--- a/sys/src/9/zynq/devether.c
+++ b/sys/src/9/zynq/devether.c
@@ -435,12 +435,6 @@
 	Ether *ether;
 	int cardno, ctlrno;
 
-	for(ctlrno = 0; ctlrno < MaxEther; ctlrno++){
-		if((ether = etherprobe(-1, ctlrno)) == nil)
-			continue;
-		etherxx[ctlrno] = ether;
-	}
-
 	cardno = ctlrno = 0;
 	while(cards[cardno].type != nil && ctlrno < MaxEther){
 		if(etherxx[ctlrno] != nil){
--- a/sys/src/9/zynq/etherif.h
+++ b/sys/src/9/zynq/etherif.h
@@ -1,5 +1,5 @@
 enum {
-	MaxEther	= 64,
+	MaxEther	= 1,
 	Ntypes		= 8,
 };
 
--