From 5f6c3d73452f9f71e5a81939a2650760fb7b9aee Mon Sep 17 00:00:00 2001 From: David Lin Date: Wed, 10 Jun 2020 10:59:50 +0800 Subject: [PATCH 1/6] Update ethernetif.c if LWIP_NETIF_HOSTNAME enable, the length is 'sizeof(struct netif)+ LWIP_HOSTNAME_LEN', not only equal to 'sizeof(struct netif)'. --- components/net/lwip-2.0.2/src/netif/ethernetif.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/components/net/lwip-2.0.2/src/netif/ethernetif.c b/components/net/lwip-2.0.2/src/netif/ethernetif.c index be16da7ad3..8d69897a4b 100644 --- a/components/net/lwip-2.0.2/src/netif/ethernetif.c +++ b/components/net/lwip-2.0.2/src/netif/ethernetif.c @@ -503,7 +503,11 @@ rt_err_t eth_device_init_with_flag(struct eth_device *dev, const char *name, rt_ rt_kprintf("malloc netif failed\n"); return -RT_ERROR; } +#if LWIP_NETIF_HOSTNAME + rt_memset(netif, 0, sizeof(struct netif)+ LWIP_HOSTNAME_LEN); +#else rt_memset(netif, 0, sizeof(struct netif)); +#endif /* set netif */ dev->netif = netif; From a5fddaecc3ccd03a0e79579a24fe8248f0706c71 Mon Sep 17 00:00:00 2001 From: David Lin Date: Wed, 10 Jun 2020 11:08:01 +0800 Subject: [PATCH 2/6] Update ethernetif.c --- components/net/lwip-1.4.1/src/netif/ethernetif.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/components/net/lwip-1.4.1/src/netif/ethernetif.c b/components/net/lwip-1.4.1/src/netif/ethernetif.c index 75f86d75d8..85ac09524b 100644 --- a/components/net/lwip-1.4.1/src/netif/ethernetif.c +++ b/components/net/lwip-1.4.1/src/netif/ethernetif.c @@ -452,7 +452,11 @@ rt_err_t eth_device_init_with_flag(struct eth_device *dev, const char *name, rt_ rt_kprintf("malloc netif failed\n"); return -RT_ERROR; } +#if LWIP_NETIF_HOSTNAME + rt_memset(netif, 0, sizeof(struct netif) + LWIP_HOSTNAME_LEN); +#else rt_memset(netif, 0, sizeof(struct netif)); +#endif /* set netif */ dev->netif = netif; From 4f53c68b3b7729642a328b0d79a20efdc85b4e6d Mon Sep 17 00:00:00 2001 From: David Lin Date: Wed, 10 Jun 2020 11:09:11 +0800 Subject: [PATCH 3/6] Update ethernetif.c --- components/net/lwip-2.1.0/src/netif/ethernetif.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/components/net/lwip-2.1.0/src/netif/ethernetif.c b/components/net/lwip-2.1.0/src/netif/ethernetif.c index 55ffaa89df..23d7180f66 100755 --- a/components/net/lwip-2.1.0/src/netif/ethernetif.c +++ b/components/net/lwip-2.1.0/src/netif/ethernetif.c @@ -499,7 +499,11 @@ rt_err_t eth_device_init_with_flag(struct eth_device *dev, const char *name, rt_ rt_kprintf("malloc netif failed\n"); return -RT_ERROR; } +#if LWIP_NETIF_HOSTNAME + rt_memset(netif, 0, sizeof(struct netif) + LWIP_HOSTNAME_LEN); +#else rt_memset(netif, 0, sizeof(struct netif)); +#endif /* set netif */ dev->netif = netif; From 8beb4399266a81162483b23dfcda19c067297929 Mon Sep 17 00:00:00 2001 From: David Lin Date: Wed, 10 Jun 2020 23:27:25 +0800 Subject: [PATCH 4/6] Update ethernetif.c --- components/net/lwip-2.0.2/src/netif/ethernetif.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/components/net/lwip-2.0.2/src/netif/ethernetif.c b/components/net/lwip-2.0.2/src/netif/ethernetif.c index 8d69897a4b..2fa528aa0d 100644 --- a/components/net/lwip-2.0.2/src/netif/ethernetif.c +++ b/components/net/lwip-2.0.2/src/netif/ethernetif.c @@ -494,20 +494,15 @@ rt_err_t eth_device_init_with_flag(struct eth_device *dev, const char *name, rt_ #if LWIP_NETIF_HOSTNAME #define LWIP_HOSTNAME_LEN 16 char *hostname = RT_NULL; - netif = (struct netif*) rt_malloc (sizeof(struct netif) + LWIP_HOSTNAME_LEN); + netif = (struct netif*) rt_calloc (1, sizeof(struct netif) + LWIP_HOSTNAME_LEN); #else - netif = (struct netif*) rt_malloc (sizeof(struct netif)); + netif = (struct netif*) rt_calloc (1, sizeof(struct netif)); #endif if (netif == RT_NULL) { rt_kprintf("malloc netif failed\n"); return -RT_ERROR; } -#if LWIP_NETIF_HOSTNAME - rt_memset(netif, 0, sizeof(struct netif)+ LWIP_HOSTNAME_LEN); -#else - rt_memset(netif, 0, sizeof(struct netif)); -#endif /* set netif */ dev->netif = netif; From aa0b68a57594a77ec9701cc89422ae461a0e4c3d Mon Sep 17 00:00:00 2001 From: David Lin Date: Wed, 10 Jun 2020 23:30:44 +0800 Subject: [PATCH 5/6] Update ethernetif.c --- components/net/lwip-1.4.1/src/netif/ethernetif.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/components/net/lwip-1.4.1/src/netif/ethernetif.c b/components/net/lwip-1.4.1/src/netif/ethernetif.c index 85ac09524b..d31ea813bc 100644 --- a/components/net/lwip-1.4.1/src/netif/ethernetif.c +++ b/components/net/lwip-1.4.1/src/netif/ethernetif.c @@ -443,20 +443,15 @@ rt_err_t eth_device_init_with_flag(struct eth_device *dev, const char *name, rt_ #if LWIP_NETIF_HOSTNAME #define LWIP_HOSTNAME_LEN 16 char *hostname = RT_NULL; - netif = (struct netif*) rt_malloc (sizeof(struct netif) + LWIP_HOSTNAME_LEN); + netif = (struct netif*) rt_calloc (1, sizeof(struct netif) + LWIP_HOSTNAME_LEN); #else - netif = (struct netif*) rt_malloc (sizeof(struct netif)); + netif = (struct netif*) rt_calloc (1, sizeof(struct netif)); #endif if (netif == RT_NULL) { rt_kprintf("malloc netif failed\n"); return -RT_ERROR; } -#if LWIP_NETIF_HOSTNAME - rt_memset(netif, 0, sizeof(struct netif) + LWIP_HOSTNAME_LEN); -#else - rt_memset(netif, 0, sizeof(struct netif)); -#endif /* set netif */ dev->netif = netif; From 822df76f8e6d3b96d93bca327bcf896b97840662 Mon Sep 17 00:00:00 2001 From: David Lin Date: Wed, 10 Jun 2020 23:32:06 +0800 Subject: [PATCH 6/6] Update ethernetif.c --- components/net/lwip-2.1.0/src/netif/ethernetif.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/components/net/lwip-2.1.0/src/netif/ethernetif.c b/components/net/lwip-2.1.0/src/netif/ethernetif.c index 23d7180f66..637b025790 100755 --- a/components/net/lwip-2.1.0/src/netif/ethernetif.c +++ b/components/net/lwip-2.1.0/src/netif/ethernetif.c @@ -490,20 +490,15 @@ rt_err_t eth_device_init_with_flag(struct eth_device *dev, const char *name, rt_ #if LWIP_NETIF_HOSTNAME #define LWIP_HOSTNAME_LEN 16 char *hostname = RT_NULL; - netif = (struct netif*) rt_malloc (sizeof(struct netif) + LWIP_HOSTNAME_LEN); + netif = (struct netif*) rt_calloc (1, sizeof(struct netif) + LWIP_HOSTNAME_LEN); #else - netif = (struct netif*) rt_malloc (sizeof(struct netif)); + netif = (struct netif*) rt_calloc (1, sizeof(struct netif)); #endif if (netif == RT_NULL) { rt_kprintf("malloc netif failed\n"); return -RT_ERROR; } -#if LWIP_NETIF_HOSTNAME - rt_memset(netif, 0, sizeof(struct netif) + LWIP_HOSTNAME_LEN); -#else - rt_memset(netif, 0, sizeof(struct netif)); -#endif /* set netif */ dev->netif = netif;