X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=src%2Fnet_setup.c;h=269b46ed0d4921d08bad76c9478d301b213ed95a;hb=4bfa6c6c9749fb3d8b73734ec7aa1ca51f813b5f;hp=a82d5d97817610ca611195927a264713e4129141;hpb=da55b444c063c510f37e4f8527982eb86f01c7b3;p=meshlink diff --git a/src/net_setup.c b/src/net_setup.c index a82d5d97..269b46ed 100644 --- a/src/net_setup.c +++ b/src/net_setup.c @@ -93,6 +93,11 @@ bool node_read_public_key(meshlink_handle_t *mesh, node_t *n) { // While we are at it, read known address information if(!n->canonical_address) { n->canonical_address = packmsg_get_str_dup(&in); + + if(!*n->canonical_address) { + free(n->canonical_address); + n->canonical_address = NULL; + } } else { packmsg_skip_element(&in); } @@ -191,6 +196,12 @@ bool node_read_from_config(meshlink_handle_t *mesh, node_t *n, const config_t *c } n->canonical_address = packmsg_get_str_dup(&in); + + if(!*n->canonical_address) { + free(n->canonical_address); + n->canonical_address = NULL; + } + uint32_t count = packmsg_get_array(&in); for(uint32_t i = 0; i < count; i++) { @@ -267,6 +278,15 @@ static bool load_node(meshlink_handle_t *mesh, const char *name, void *priv) { (void)priv; if(!check_id(name)) { + // Check if this is a temporary file, if so remove it + const char *suffix = strstr(name, ".tmp"); + + if(suffix && !suffix[4]) { + char filename[PATH_MAX]; + snprintf(filename, sizeof(filename), "%s" SLASH "current" SLASH "hosts", mesh->confbase); + unlink(filename); + } + return true; }