]> git.meshlink.io Git - meshlink/commitdiff
Don't store empty canonical addresses.
authorGuus Sliepen <guus@meshlink.io>
Mon, 13 Jul 2020 20:40:06 +0000 (22:40 +0200)
committerGuus Sliepen <guus@meshlink.io>
Wed, 22 Jul 2020 13:01:22 +0000 (15:01 +0200)
Use a NULL pointer instead of an empty string to signal the lack of a
canonical address.

src/net_setup.c

index a82d5d97817610ca611195927a264713e4129141..b289a76504da93fed6159e7a2f1c0651fc9949bc 100644 (file)
@@ -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++) {