Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions components/net/lwip/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ if RT_USING_LWIP
config RT_LWIP_NETIF_NAMESIZE
int "netif name length"
default 6
range 3 32

config SO_REUSE
int "Enable SO_REUSEADDR option"
Expand Down
3 changes: 1 addition & 2 deletions components/net/lwip/lwip-2.1.2/src/netif/ppp/ppp.c
Original file line number Diff line number Diff line change
Expand Up @@ -469,8 +469,7 @@ static void ppp_do_connect(void *arg) {
* ppp_netif_init_cb - netif init callback
*/
static err_t ppp_netif_init_cb(struct netif *netif) {
netif->name[0] = 'p';
netif->name[1] = 'p';
strncpy(netif->name, "pp", sizeof(netif->name));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

建议改成rt_strncpy

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2.0.3的一起修改下?

static err_t ppp_netif_init_cb(struct netif *netif) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

而且我看这个PR修改的是LWIP源码,看了下官方上游也是这么写的,感觉这么改不是很好
感觉应该从软件包上着手修改下

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

其实可以在ppp-device中,修改所有的class,将ppp_device = rt_malloc(sizeof(struct ppp_device));改为ppp_device = rt_calloc(1, sizeof(struct ppp_device));就可以解决。但是这样需要依赖ppp-device软件包去确保name不会被污染,感觉不够稳妥。

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

另外,因为是lwip的代码,所以我没用上rtthreadrt_strncpy,而是strncpy
不过里面已经引用了rtthread,那使用rt_strncpy也合理

#if PPP_IPV4_SUPPORT
netif->output = ppp_netif_output_ip4;
#endif /* PPP_IPV4_SUPPORT */
Expand Down
Loading