]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
client: fix truncation of long hostnames
authorMiroslav Lichvar <mlichvar@redhat.com>
Mon, 5 Dec 2016 09:37:44 +0000 (10:37 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Tue, 6 Dec 2016 15:56:38 +0000 (16:56 +0100)
client.c

index 00b8aa208d90096bf659c113d24a595ff798ec59..d0e90941b577f1d57f9af2d6270e8d39c5306b46 100644 (file)
--- 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';
     }
   }