* [PATCH] ibmtr: possible Read buffer overflow?
@ 2009-10-03 21:26 Roel Kluin
2009-10-30 5:54 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Roel Kluin @ 2009-10-03 21:26 UTC (permalink / raw)
To: David S. Miller, netdev, Andrew Morton
Prevent read outside array bounds.
Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
Is this maybe required?
build tested
diff --git a/drivers/net/tokenring/ibmtr.c b/drivers/net/tokenring/ibmtr.c
index 525bbc5..6a3c751 100644
--- a/drivers/net/tokenring/ibmtr.c
+++ b/drivers/net/tokenring/ibmtr.c
@@ -1143,9 +1143,16 @@ static void dir_open_adapter (struct net_device *dev)
} else {
char **prphase = printphase;
char **prerror = printerror;
+ int pnr = err / 16 - 1;
+ int enr = err % 16 - 1;
DPRINTK("TR Adapter misc open failure, error code = ");
- printk("0x%x, Phase: %s, Error: %s\n",
- err, prphase[err/16 -1], prerror[err%16 -1]);
+ if (pnr < 0 || pnr >= ARRAY_SIZE(printphase) ||
+ enr < 0 ||
+ enr >= ARRAY_SIZE(printerror))
+ printk("0x%x, invalid Phase/Error.", err);
+ else
+ printk("0x%x, Phase: %s, Error: %s\n", err,
+ prphase[pnr], prerror[enr]);
printk(" retrying after %ds delay...\n",
TR_RETRY_INTERVAL/HZ);
}
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-10-30 5:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-03 21:26 [PATCH] ibmtr: possible Read buffer overflow? Roel Kluin
2009-10-30 5:54 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).