Fix SEGFAULT when trying to connect to IPv6 peer in non-IPv6 environment
authorMaximilian Stein <m@steiny.biz>
Mon, 15 Jan 2018 23:45:38 +0000 (00:45 +0100)
committerGuus Sliepen <guus@tinc-vpn.org>
Tue, 16 Jan 2018 06:50:39 +0000 (07:50 +0100)
Using my tinc setup I observe spurious SEGFAULTs in the daemon process.

My configuration comprises a proxy (type exec) and the peer's address is
given by its domain name. The domain resolves to both IPv4 and IPv6.
As IPv6 is not working in my environment, all connection attempts to the
resolved IPv6 addresses fail. Sometimes, after such a failure, the
segfault occurs.

Apparently, the issue is caused by a use after free due to failing to
reset a pointer.

src/net.c

index 4b64492dfcaa8ef91237104f87ead6a4d49d18fd..1fecd88fd00d0038e0020124cc303680022e5a33 100644 (file)
--- a/src/net.c
+++ b/src/net.c
@@ -218,6 +218,7 @@ void terminate_connection(connection_t *c, bool report) {
                }
 
                edge_del(c->edge);
+               c->edge = NULL;
 
                /* Run MST and SSSP algorithms */