Skip to contentSkip to conversation

Array overrun in drivers/net/wireless/wavelan.c

PATCH New Eric Sesterhenn 1 participant 1 message Jun 21, 2006 Networking drivers (wireless)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Array overrun in drivers/net/wireless/wavelan.c

hi,

this is another array overrun spotted by coverity (#id 507) we should check the index against array size before using it. Not sure why the driver doesnt use ARRAY_SIZE instead of its own macro.

drivers/net/wireless/wavelan.c renamed from drivers/net/wireless/wavelan.c.orig +2 -2
@@ -1695,8 +1695,8 @@ static int wv_frequency_list(unsigned lo
 		/* Look in the table if the frequency is allowed */
 		if (table[9 - (freq / 16)] & (1 << (freq % 16))) {
 			/* Compute approximate channel number */
-			while ((((channel_bands[c] >> 1) - 24) < freq) &&
-			       (c < NELS(channel_bands)))
+			while ((c < NELS(channel_bands)) &&
+				(((channel_bands[c] >> 1) - 24) < freq)) 
 				c++;
 			list[i].i = c;	/* Set the list index */