From 1bfd9ff74fb8618fd6accb6716331536a36f032a Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Thu, 15 Apr 2021 20:40:22 +0200 Subject: [PATCH] Fix a compiler warning. --- src/protocol_key.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/protocol_key.c b/src/protocol_key.c index 6a2946eb..b2ba50fe 100644 --- a/src/protocol_key.c +++ b/src/protocol_key.c @@ -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; } -- 2.39.5