segfault in current svn

Markus Barenhoff mbarenh at alios.org
Thu Mar 31 01:09:01 CEST 2005


hi there !

the current version of tinc crashes with a segfault. it seems, as if has 
to to with fact, that i don`t have configured any subnets....

if the client tries to start up subnet_update() ist called for myself.
the for iteration does not get an entry (because the subnet avl-tree is 
empty).

the later call of net2str causes a segfault, because it gets an empty 
subnet and tries to access the type field of the subnet structure.

i included a patch wich checks the subnet pointer before calling the 
net2str function, and a small check inside the net2str function which 
checks the giben subnet argument against NULL (and so makes use of the 
return value :) )

greets Markus

-- 
Markus Barenhoff - Spannskamp 26 - D-22527 Hamburg - Germany
Phone: +49-40-39991368 Cell: +49-173-7215776
eMail: barenh_m at informatik.haw-hamburg.de pgp key: (keyID:0xAE7C7759)
FingerPrint: 79 64 AA D9 B7 16 F5 06  6A 88 5F A9 4D 49 45 BB
-------------- next part --------------
diff -u /tmp/tinc/src/subnet.c /home/mbarenh/daten/tinc/src/subnet.c
--- /tmp/tinc/src/subnet.c	2005-03-31 00:49:40.318462040 +0200
+++ /home/mbarenh/daten/tinc/src/subnet.c	2005-03-31 01:01:54.595834912 +0200
@@ -247,6 +247,10 @@
 {
 	cp();
 
+	/* check if we have a subnet */
+	if (!subnet)
+	  return false;
+
 	switch (subnet->type) {
 		case SUBNET_MAC:
 			snprintf(netstr, len, "%hx:%hx:%hx:%hx:%hx:%hx",
@@ -421,10 +425,12 @@
 		}
 	} else {
 		if(net2str(netstr + 7, sizeof netstr - 7, subnet))
-			execute_script(name, envp);
-	}
+			execute_script(name, envp);	}
+
+	/* do this only if we have a subnet (subnet != NULL) */
+	if(subnet)
+	  net2str(netstr, sizeof netstr, subnet);
 
-	net2str(netstr, sizeof netstr, subnet);
 	envp[6] = envp[7] = NULL;
 
 	for(i = 0; i < (owner != myself ? 6 : 4); i++)


More information about the tinc mailing list