Device driver name - NET_MULTI
Hi,
I have met with the problem where I setup longer network driver name than was allocated space in eth_device structure.
That's why I think that registration code should check it.
What do you think?
Thanks,
Michal
RFC PATCH 1/1 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
--- net/eth.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-)
net/eth.c +7 -0
@@ -191,6 +191,13 @@ static void eth_current_changed(void)int eth_register (struct eth_device *dev) {struct eth_device *d; + +if (strlen (dev->name) >NAMESIZE ) { +printf ("Long(%d>%d) network driver name for %s\n" , +strlen (dev->name),NAMESIZE , dev->name); +return 0 ; + } +if (!eth_devices) { eth_current = eth_devices = dev;eth_current_changed ();
Signature · 1 line
1.5.5.6
RFC PATCH 1/1 net: Check network device driver name
Quoted 3 lines · On Friday, August 26, 2011 08:52:40 Michal Simek wrote:
If name is longer than allocated space NAMESIZE
mac address is rewritten which show error
message like:
since you overflowed the buffer, who knows what could happen ...
net/eth.c static void eth_current_changed(void) · line 199
Quoted 5 lines
net/eth.c +5
-0+if (strlen (dev->name) >NAMESIZE ) { +printf ("Long(%d>%d) network driver name for %s\n" , +strlen (dev->name),NAMESIZE , dev->name); +return 0 ; + }
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;
}-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20110826/44f59aee/attachment.pgp
RFC PATCH 1/1 net: Check network device driver name
Quoted 14 lines · Mike Frysinger
Quoted 3 lines · On Friday, August 26, 2011 08:52:40 Michal Simek wrote:
If name is longer than allocated space NAMESIZE
mac address is rewritten which show error
message like:since you overflowed the buffer, who knows what could happen ...
net/eth.c static void eth_current_changed(void) · line 199
Quoted 5 lines
net/eth.c +5
-0+if (strlen (dev->name) >NAMESIZE ) { +printf ("Long(%d>%d) network driver name for %s\n" , +strlen (dev->name),NAMESIZE , dev->name); +return 0 ; + }
size_tlen =strlen(dev->name);
Quoted 5 lines
if (len >= NAMESIZE) {
printf("network driver name is too long (%zu >= %zu): %s\n",
len, NAMESIZE, dev->name);
return -1;
}ok. I see it is 15 chars space + terminated characters.
Mike: Will you propose this patch or should I do it?
Thanks,
Michal
Signature · 4 lines
Michal Simek, Ing. (M.Eng) w: www.monstr.eu p: +42-0-721842854 Maintainer of Linux kernel 2.6 Microblaze Linux - http://www.monstr.eu/fdt/ Microblaze U-BOOT custodian
RFC PATCH 1/1 net: Check network device driver name
Quoted 21 lines · On Monday, August 29, 2011 04:07:14 Michal Simek wrote:
Quoted 20 lines · Mike Frysinger
Quoted 4 lines · On Friday, August 26, 2011 08:52:40 Michal Simek wrote:
If name is longer than allocated space NAMESIZE
mac address is rewritten which show errormessage like:
since you overflowed the buffer, who knows what could happen ...
net/eth.c static void eth_current_changed(void) · line 199
Quoted 5 lines
net/eth.c +5
-0+if (strlen (dev->name) >NAMESIZE ) { +printf ("Long(%d>%d) network driver name for %s\n" , +strlen (dev->name),NAMESIZE , dev->name); +return 0 ; + }
size_tlen =strlen(dev->name);
if (len >= NAMESIZE) {printf("network driver name is too long (%zu >= %zu): %s\n", len, NAMESIZE, dev->name);
Quoted 7 lines
Quoted 3 lines
return -1;}
ok. I see it is 15 chars space + terminated characters.
Mike: Will you propose this patch or should I do it?
since you've got stuff pending here, best for you to do it :)
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20110829/1d90dd74/attachment.pgp