All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] Device driver name - NET_MULTI
@ 2011-08-26 12:52 Michal Simek
  2011-08-26 12:52 ` [U-Boot] [RFC PATCH] net: Check network device driver name Michal Simek
  0 siblings, 1 reply; 5+ messages in thread
From: Michal Simek @ 2011-08-26 12:52 UTC (permalink / raw)
  To: u-boot

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [U-Boot] [RFC PATCH] net: Check network device driver name
  2011-08-26 12:52 [U-Boot] Device driver name - NET_MULTI Michal Simek
@ 2011-08-26 12:52 ` Michal Simek
  2011-08-26 19:52   ` Mike Frysinger
  0 siblings, 1 reply; 5+ messages in thread
From: Michal Simek @ 2011-08-26 12:52 UTC (permalink / raw)
  To: u-boot

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

Signed-off-by: Michal Simek <monstr@monstr.eu>
---
 net/eth.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/net/eth.c b/net/eth.c
index 3aad71f..54231b1 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -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();
-- 
1.5.5.6

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [U-Boot] [RFC PATCH] net: Check network device driver name
  2011-08-26 12:52 ` [U-Boot] [RFC PATCH] net: Check network device driver name Michal Simek
@ 2011-08-26 19:52   ` Mike Frysinger
  2011-08-29  8:07     ` Michal Simek
  0 siblings, 1 reply; 5+ messages in thread
From: Mike Frysinger @ 2011-08-26 19:52 UTC (permalink / raw)
  To: u-boot

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 ...

> +	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 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [U-Boot] [RFC PATCH] net: Check network device driver name
  2011-08-26 19:52   ` Mike Frysinger
@ 2011-08-29  8:07     ` Michal Simek
  2011-08-29 18:17       ` Mike Frysinger
  0 siblings, 1 reply; 5+ messages in thread
From: Michal Simek @ 2011-08-29  8:07 UTC (permalink / raw)
  To: u-boot

Mike Frysinger wrote:
> 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 ...
> 
>> +	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;
> }

ok. I see it is 15 chars space + terminated characters.

Mike: Will you propose this patch or should I do it?

Thanks,
Michal





-- 
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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [U-Boot] [RFC PATCH] net: Check network device driver name
  2011-08-29  8:07     ` Michal Simek
@ 2011-08-29 18:17       ` Mike Frysinger
  0 siblings, 0 replies; 5+ messages in thread
From: Mike Frysinger @ 2011-08-29 18:17 UTC (permalink / raw)
  To: u-boot

On Monday, August 29, 2011 04:07:14 Michal Simek wrote:
> Mike Frysinger wrote:
> > 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 ...
> > 
> >> +	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;
> > 
> > }
> 
> 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 

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-08-29 18:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-26 12:52 [U-Boot] Device driver name - NET_MULTI Michal Simek
2011-08-26 12:52 ` [U-Boot] [RFC PATCH] net: Check network device driver name Michal Simek
2011-08-26 19:52   ` Mike Frysinger
2011-08-29  8:07     ` Michal Simek
2011-08-29 18:17       ` Mike Frysinger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.