Skip to contentSkip to conversation

tulip_core.c : out-of-bounds check.

PATCH Applied Ameen Ali 3 participants 3 messages Mar 13, 2015

Subsystems (3)
lore
Share & tools
lore

Ameen Ali

author
#0 lore raw

PATCH 9/9 tulip_core.c : out-of-bounds check.

Array index 'j' is used before limits check.

Suggest put limit check before index use.

Signed-off-by <[email protected]>
---
 drivers/net/ethernet/dec/tulip/tulip_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/dec/tulip/tulip_core.c +1 -1
index 3b42556..ed41559 100644
@@ -589,7 +589,7 @@ static void tulip_tx_timeout(struct net_device *dev)
 			       (unsigned int)tp->rx_ring[i].buffer1,
 			       (unsigned int)tp->rx_ring[i].buffer2,
 			       buf[0], buf[1], buf[2]);
-			for (j = 0; buf[j] != 0xee && j < 1600; j++)
+			for (j = 0; ((j < 1600) && buf[j] != 0xee); j++)
 				if (j < 100)
 					pr_cont(" %02x", buf[j]);
 			pr_cont(" j=%d\n", j);
Signature · 1 line
2.1.0
#2 lore raw
In reply to Ameen Ali

Hello.

Quoted 14 lines · Ameen Ali

Array index 'j' is used before limits check.

Suggest put limit check before index use.

Signed-off-by <[email protected]>
---
  drivers/net/ethernet/dec/tulip/tulip_core.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/dec/tulip/tulip_core.c +0 -0
index 3b42556..ed41559 100644

drivers/net/ethernet/dec/tulip/tulip_core.c static void tulip_tx_timeout(struct net_device *dev) · line 592

Quoted 5 lines
drivers/net/ethernet/dec/tulip/tulip_core.c +1 -1
@@ -589,7 +589,7 @@ static void tulip_tx_timeout(struct net_device *dev)
  			       (unsigned int)tp->rx_ring[i].buffer1,
  			       (unsigned int)tp->rx_ring[i].buffer2,
  			       buf[0], buf[1], buf[2]);
-			for (j = 0; buf[j] != 0xee && j < 1600; j++)
+			for (j = 0; ((j < 1600) && buf[j] != 0xee); j++)

No need for extra parens, either around < or around &&.

WBR, Sergei