summaryrefslogtreecommitdiff
path: root/net/eth.c
diff options
context:
space:
mode:
authorMichal Simek <monstr@monstr.eu>2011-08-29 23:30:13 +0000
committerWolfgang Denk <wd@denx.de>2011-09-04 23:29:39 +0200
commit58c583b6c2ebc459de018c772fea5437de430063 (patch)
tree04b450fcb1f6bc4d817bce1f685b5ae1cdfe2e48 /net/eth.c
parent03bf22f55990d27a1d3a5f8c6f8c94fb400f77d4 (diff)
net: Check network device driver name
If name is longer than allocated space NAMESIZE mac address is rewritten which show error message like: Error message: Warning: Xlltemac.87000000 MAC addresses don't match: Address in SROM is 30:00:00:00:00:00 Address in environment is 00:0a:35:00:6a:04 NAMESIZE contains Driver name + zero terminated character. Signed-off-by: Michal Simek <monstr@monstr.eu>
Diffstat (limited to 'net/eth.c')
-rw-r--r--net/eth.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/net/eth.c b/net/eth.c
index a34fe59383..c9b7e85e39 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -224,6 +224,14 @@ int eth_write_hwaddr(struct eth_device *dev, const char *base_name,
int eth_register(struct eth_device *dev)
{
struct eth_device *d;
+
+ size_t len = strlen(dev->name);
+ if (len >= NAMESIZE) {
+ printf("Network driver name is too long (%zu >= %zu): %s\n",
+ len, NAMESIZE, dev->name);
+ return -1;
+ }
+
if (!eth_devices) {
eth_current = eth_devices = dev;
eth_current_changed();