Skip to contentSkip to conversation

hysdn: Fix writing outside the field on 64 bits

PATCH New Pascal Terjan 1 participant 1 message Nov 25, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hysdn: Fix writing outside the field on 64 bits

ifa_local is assumed to be unsigned long which lead to writing the address at dev->dev_addr-2 instead of +2

noticed thanks to gcc:

drivers/isdn/hysdn/hysdn_net.c: In function ‘net_open’:
drivers/isdn/hysdn/hysdn_net.c:91: warning: array subscript is below array bounds

---
 drivers/isdn/hysdn/hysdn_net.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
drivers/isdn/hysdn/hysdn_net.c +2 -2
index cfa8fa5..7358712 100644
@@ -83,12 +83,12 @@ net_open(struct net_device *dev)
 
 	/* Fill in the MAC-level header (if not already set) */
 	if (!card->mac_addr[0]) {
-		for (i = 0; i < ETH_ALEN - sizeof(unsigned long); i++)
+		for (i = 0; i < ETH_ALEN; i++)
 			dev->dev_addr[i] = 0xfc;
 		if ((in_dev = dev->ip_ptr) != NULL) {
 			struct in_ifaddr *ifa = in_dev->ifa_list;
 			if (ifa != NULL)
-				memcpy(dev->dev_addr + (ETH_ALEN - sizeof(unsigned long)), &ifa->ifa_local, sizeof(unsigned long));
+				memcpy(dev->dev_addr + (ETH_ALEN - sizeof(ifa->ifa_local)), &ifa->ifa_local, sizeof(ifa->ifa_local));
 		}
 	} else
 		memcpy(dev->dev_addr, card->mac_addr, ETH_ALEN);
Signature · 1 line
1.6.0.4