From: Guus Sliepen Date: Mon, 13 Jul 2020 20:40:06 +0000 (+0200) Subject: Don't store empty canonical addresses. X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=0298c10effe496200dc761a4a26d57fc01ee2cf8;p=meshlink Don't store empty canonical addresses. Use a NULL pointer instead of an empty string to signal the lack of a canonical address. --- diff --git a/src/net_setup.c b/src/net_setup.c index a82d5d97..b289a765 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++) {