From 0298c10effe496200dc761a4a26d57fc01ee2cf8 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Mon, 13 Jul 2020 22:40:06 +0200 Subject: [PATCH] Don't store empty canonical addresses. Use a NULL pointer instead of an empty string to signal the lack of a canonical address. --- src/net_setup.c | 11 +++++++++++ 1 file changed, 11 insertions(+) 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++) { -- 2.39.5