Fix a possible crash when sending the HUP signal.

When the HUP signal is sent while some outgoing connections have not been made
yet, or are being retried, a NULL pointer could be dereferenced resulting in
tinc crashing. We fix this by more careful handling of outgoing_ts, and by
deleting all connections that have not been fully activated yet at the HUP
signal is received.
This commit is contained in:
Guus Sliepen 2009-10-20 22:14:47 +02:00
parent 8c267d3d55
commit 35af4051c3
5 changed files with 51 additions and 21 deletions

View file

@ -431,7 +431,7 @@ int main_loop(void) {
if(sighup) {
connection_t *c;
avl_node_t *node;
avl_node_t *node, *next;
char *fname;
struct stat s;
@ -447,6 +447,31 @@ int main_loop(void) {
return 1;
}
/* Cancel non-active outgoing connections */
for(node = connection_tree->head; node; node = next) {
next = node->next;
c = node->data;
c->outgoing = NULL;
if(c->status.connecting) {
terminate_connection(c, false);
connection_del(c);
}
}
/* Wipe list of outgoing connections */
for(list_node_t *node = outgoing_list->head; node; node = node->next) {
outgoing_t *outgoing = node->data;
if(outgoing->event)
event_del(outgoing->event);
}
list_delete_list(outgoing_list);
/* Close connections to hosts that have a changed or deleted host config file */
for(node = connection_tree->head; node; node = node->next) {