projects
/
tinc
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Ensure send_udp_probe_packet len is valid for the buffer size.
[tinc]
/
src
/
edge.c
diff --git
a/src/edge.c
b/src/edge.c
index
0e35cd1
..
86970ce
100644
(file)
--- a/
src/edge.c
+++ b/
src/edge.c
@@
-1,6
+1,6
@@
/*
edge.c -- edge tree management
/*
edge.c -- edge tree management
- Copyright (C) 2000-20
13
Guus Sliepen <guus@tinc-vpn.org>,
+ Copyright (C) 2000-20
21
Guus Sliepen <guus@tinc-vpn.org>,
2000-2005 Ivo Timmermans
This program is free software; you can redistribute it and/or modify
2000-2005 Ivo Timmermans
This program is free software; you can redistribute it and/or modify
@@
-40,13
+40,15
@@
static int edge_weight_compare(const edge_t *a, const edge_t *b) {
result = a->weight - b->weight;
result = a->weight - b->weight;
- if(result)
+ if(result)
{
return result;
return result;
+ }
result = strcmp(a->from->name, b->from->name);
result = strcmp(a->from->name, b->from->name);
- if(result)
+ if(result)
{
return result;
return result;
+ }
return strcmp(a->to->name, b->to->name);
}
return strcmp(a->to->name, b->to->name);
}
@@
-81,18
+83,32
@@
void free_edge(edge_t *e) {
}
void edge_add(edge_t *e) {
}
void edge_add(edge_t *e) {
- splay_insert(edge_weight_tree, e);
- splay_insert(e->from->edge_tree, e);
+ splay_node_t *node = splay_insert(e->from->edge_tree, e);
+
+ if(!node) {
+ logger(DEBUG_ALWAYS, LOG_ERR, "Edge from %s to %s already exists in edge_tree\n", e->from->name, e->to->name);
+ return;
+ }
+
e->reverse = lookup_edge(e->to, e->from);
e->reverse = lookup_edge(e->to, e->from);
- if(e->reverse)
+ if(e->reverse)
{
e->reverse->reverse = e;
e->reverse->reverse = e;
+ }
+
+ node = splay_insert(edge_weight_tree, e);
+
+ if(!node) {
+ logger(DEBUG_ALWAYS, LOG_ERR, "Edge from %s to %s already exists in edge_weight_tree\n", e->from->name, e->to->name);
+ return;
+ }
}
void edge_del(edge_t *e) {
}
void edge_del(edge_t *e) {
- if(e->reverse)
+ if(e->reverse)
{
e->reverse->reverse = NULL;
e->reverse->reverse = NULL;
+ }
splay_delete(edge_weight_tree, e);
splay_delete(e->from->edge_tree, e);
splay_delete(edge_weight_tree, e);
splay_delete(e->from->edge_tree, e);
@@
-111,11
+127,11
@@
bool dump_edges(connection_t *c) {
for splay_each(node_t, n, node_tree) {
for splay_each(edge_t, e, n->edge_tree) {
char *address = sockaddr2hostname(&e->address);
for splay_each(node_t, n, node_tree) {
for splay_each(edge_t, e, n->edge_tree) {
char *address = sockaddr2hostname(&e->address);
- char
*
local_address = sockaddr2hostname(&e->local_address);
+ char
*
local_address = sockaddr2hostname(&e->local_address);
send_request(c, "%d %d %s %s %s %s %x %d",
send_request(c, "%d %d %s %s %s %s %x %d",
-
CONTROL, REQ_DUMP_EDGES,
-
e->from->name, e->to->name, address,
-
local_address, e->options, e->weight);
+ CONTROL, REQ_DUMP_EDGES,
+ e->from->name, e->to->name, address,
+ local_address, e->options, e->weight);
free(address);
free(local_address);
}
free(address);
free(local_address);
}