Skip to content

zerotier-openwrt is not compatible with 24.10.0 #137

Open
@rabbitrogi

Description

@rabbitrogi

zerotier-openwrt is working very well in 23.05.5, but in 24.10.0 will got a 'Segmentation fault'.

In 23.05.5, miniupnpc is 2.2.3, but in 24.10.0, miniupnpc is 2.2.8.

In miniupnpc-2.2.3/include/miniupnpc.h, line 119 to 123 is:

MINIUPNP_LIBSPEC int
UPNP_GetValidIGD(struct UPNPDev * devlist,
                 struct UPNPUrls * urls,
                 struct IGDdatas * data,
                 char * lanaddr, int lanaddrlen);

In miniupnpc-2.2.8/include/miniupnpc.h, line 121 to 126 is:

MINIUPNP_LIBSPEC int
UPNP_GetValidIGD(struct UPNPDev * devlist,
                 struct UPNPUrls * urls,
                 struct IGDdatas * data,
                 char * lanaddr, int lanaddrlen,
                 char * wanaddr, int wanaddrlen);

But in ZeroTierOne-1.14.1/osdep/PortMapper.cpp, line 233 is:

if ((foundValidIGD = UPNP_GetValidIGD(devlist,&urls,&data,lanaddr,sizeof(lanaddr)))&&(lanaddr[0])) {

So we need to define a new 'wanaddr' to fix this problem.

This patch may fix the crash:
https://gitlab.archlinux.org/archlinux/packaging/packages/zerotier-one/-/commit/1d040aee9a4cfecdcc747cb42f92a1420a42a3f4

gdb /usr/bin/zerotier-one zerotier-one.1740455801.1387.11.core 
GNU gdb (GDB) 15.2
Copyright (C) 2024 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "aarch64-openwrt-linux".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/bin/zerotier-one...
[New LWP 1474]
[New LWP 1410]
[New LWP 1387]
[New LWP 1475]
[New LWP 1494]
[New LWP 1506]
[New LWP 1497]
[New LWP 1496]
[New LWP 1503]
[New LWP 1499]
[New LWP 1500]
[New LWP 1505]
[New LWP 1502]
[New LWP 1498]
[New LWP 1507]
[New LWP 1501]
[New LWP 1508]
[New LWP 1509]
[New LWP 1476]
[New LWP 1491]
[New LWP 1495]
[New LWP 1504]
[New LWP 1493]
Core was generated by `/usr/bin/zerotier-one -p26783'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  memset () at src/string/aarch64/memset.S:94

warning: 94	src/string/aarch64/memset.S: No such file or directory
[Current thread is 1 (LWP 1474)]
(gdb) bt
#0  memset () at src/string/aarch64/memset.S:94
#1  0x0000007f91500a44 in __stpncpy (d=d@entry=0x7f90f5bb95 "", s=<optimized out>, s@entry=0x7f90c05678 "", n=<optimized out>, n@entry=808464691) at src/string/stpncpy.c:27
#2  0x0000007f915011c4 in strncpy (d=d@entry=0x7f90f5bb95 "", s=s@entry=0x7f90c05678 "", n=n@entry=808464691) at src/string/strncpy.c:5
#3  0x0000007f9148039c in UPNP_GetValidIGD (devlist=0x7f8f9962f0, urls=0x7f90f5bb10, data=0x7f90f5beb0, lanaddr=0x7f90f5ca38 "", lanaddrlen=4096, wanaddr=0x7f90f5bb95 "", 
    wanaddrlen=808464691) at miniupnpc-2.2.8/src/miniupnpc.c:649
#4  0x000000000054c580 in ZeroTier::PortMapperImpl::threadMain (this=0x7f90f67be0) at osdep/PortMapper.cpp:233
#5  0x0000000000000000 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb) q

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions