]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
misc.cc: Resize hostname to final size in getCarbonHostname()
authorAki Tuomi <cmouse@cmouse.fi>
Sun, 19 Jul 2020 15:06:14 +0000 (18:06 +0300)
committerAki Tuomi <cmouse@cmouse.fi>
Tue, 21 Jul 2020 19:14:14 +0000 (22:14 +0300)
In 5c21b47fbc35ddcb8d939eb8541c6c3bad1080a8 we change how
hostname is allocated. We allocate getMaxHostNameSize for string,
then give the raw buffer for gethostname function, but forget to
resize the string into actual result length, causing the carbon
output to include trailing NUL bytes after hostname.

pdns/misc.cc

index 0215e8e42c5f9500446ed8e45cbf953ada6fe2eb..ef743a8e75172c25d6671655334870726aab9774 100644 (file)
@@ -1589,6 +1589,7 @@ std::string getCarbonHostName()
   }
 
   boost::replace_all(hostname, ".", "_");
+  hostname.resize(strlen(hostname.c_str()));
 
   return hostname;
 }