]> git.meshlink.io Git - meshlink/commitdiff
Fix a compiler warning.
authorGuus Sliepen <guus@meshlink.io>
Thu, 15 Apr 2021 18:40:22 +0000 (20:40 +0200)
committerGuus Sliepen <guus@meshlink.io>
Thu, 15 Apr 2021 18:40:22 +0000 (20:40 +0200)
src/protocol_key.c

index 6a2946eb8d6ca22be39d3cbcea42fcb0a9c181d3..b2ba50fe14de198573fc1a9424c6b2e6ddf28327 100644 (file)
@@ -275,16 +275,15 @@ static bool req_key_ext_h(meshlink_handle_t *mesh, connection_t *c, const char *
                        return true;
                }
 
-               strncat(host, " ", MAX_STRING_SIZE - 1);
-               strncat(host, port, MAX_STRING_SIZE - 1);
+               char *canonical_address;
+               xasprintf(&canonical_address, "%s %s", host, port);
 
-               if(from->canonical_address && !strcmp(from->canonical_address, host)) {
-                       return true;
+               if(mesh->log_level <= MESHLINK_DEBUG && strcmp(from->canonical_address, canonical_address)) {
+                       logger(mesh, MESHLINK_DEBUG, "Updating canonical address of %s to %s", from->name, canonical_address);
                }
 
-               logger(mesh, MESHLINK_DEBUG, "Updating canonical address of %s to %s", from->name, host);
                free(from->canonical_address);
-               from->canonical_address = xstrdup(host);
+               from->canonical_address = canonical_address;
                return true;
        }