On 2011-04-18 16:24, Sebastian Smolorz wrote:
> Since kernel 2.6.31 dev_addr in struct net_device is a pointer and
> not an array itself. Memcpying or memsetting the MAC address with
> a sizeof(dev_addr) as length argument does not work properly as
> now the length of the pointer is taken and not the size of the
> array.
> 
> This patch sets the memcpy and memset lengths in three files to
> MAX_ADDR_LEN. This define exists in the kernel since the old 2.4
> days and didn't change its meaning, so it can be considered as a
> safe length to use for these memcpy and memset operations.
> 
> Signed-off-by: Sebastian Smolorz <[email protected]>
> ---
>  addons/rtcap.c           |    2 +-
>  addons/rtnetproxy.c      |    2 +-
>  stack/rtmac/rtmac_vnic.c |    2 +-
>  3 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/addons/rtcap.c b/addons/rtcap.c
> index c4a2ccb..ca58391 100644
> --- a/addons/rtcap.c
> +++ b/addons/rtcap.c
> @@ -302,7 +302,7 @@ static int tap_dev_open(struct net_device *dev)
>  {
>      memcpy(dev->dev_addr,
>             (*(struct rtnet_device **)netdev_priv(dev))->dev_addr,
> -           sizeof(dev->dev_addr));
> +           MAX_ADDR_LEN);
>  
>      return 0;
>  }
> diff --git a/addons/rtnetproxy.c b/addons/rtnetproxy.c
> index 2358d09..36d662b 100644
> --- a/addons/rtnetproxy.c
> +++ b/addons/rtnetproxy.c
> @@ -464,7 +464,7 @@ static int __init rtnetproxy_init(struct net_device *dev)
>      ether_setup(dev);
>      dev->tx_queue_len = 0;
>  #ifdef CONFIG_RTNET_ADDON_PROXY_ARP
> -    memcpy(dev->dev_addr, rtnetproxy_rtdev->dev_addr, sizeof(dev->dev_addr));
> +    memcpy(dev->dev_addr, rtnetproxy_rtdev->dev_addr, MAX_ADDR_LEN);
>  #else
>      dev->flags |= IFF_NOARP;
>  #endif
> diff --git a/stack/rtmac/rtmac_vnic.c b/stack/rtmac/rtmac_vnic.c
> index 5358028..9e929c5 100644
> --- a/stack/rtmac/rtmac_vnic.c
> +++ b/stack/rtmac/rtmac_vnic.c
> @@ -131,7 +131,7 @@ static int rtmac_vnic_copy_mac(struct net_device *dev)
>  {
>      memcpy(dev->dev_addr,
>             (*(struct rtnet_device **)netdev_priv(dev))->dev_addr,
> -           sizeof(dev->dev_addr));
> +           MAX_ADDR_LEN);
>  
>      return 0;
>  }

Thanks, applied and now also pushed.

Jan

Attachment: signature.asc
Description: OpenPGP digital signature

------------------------------------------------------------------------------
Benefiting from Server Virtualization: Beyond Initial Workload 
Consolidation -- Increasing the use of server virtualization is a top
priority.Virtualization can reduce costs, simplify management, and improve 
application availability and disaster protection. Learn more about boosting 
the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev
_______________________________________________
RTnet-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rtnet-developers

Reply via email to