From 46061d8eecc697b843a1d4b5dd7b821c4458536a Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Mon, 5 Dec 2016 10:37:44 +0100 Subject: [PATCH] client: fix truncation of long hostnames --- client.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/client.c b/client.c index 00b8aa2..d0e9094 100644 --- a/client.c +++ b/client.c @@ -1952,9 +1952,8 @@ format_name(char *buf, int size, int trunc_dns, int ref, uint32_t ref_id, snprintf(buf, size, "%s", UTI_IPToString(ip_addr)); } else { DNS_IPAddress2Name(ip_addr, buf, size); - if (size > trunc_dns) { - if (trunc_dns > 0) - buf[trunc_dns - 1] = '>'; + if (trunc_dns > 0 && strlen(buf) > trunc_dns) { + buf[trunc_dns - 1] = '>'; buf[trunc_dns] = '\0'; } }