]> 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)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Fri, 31 Jul 2020 08:09:13 +0000 (10:09 +0200)
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.

(cherry picked from commit 57f8ac68b4fa7063fd2cac4d5b77045e0255c770)

pdns/misc.cc

index 5cb4dbe8128d60145df6bbfdde30e479c27e260e..332a7c2a9cae1e3b2a1403f6d7c861a52e1e9e69 100644 (file)
@@ -1597,6 +1597,7 @@ std::string getCarbonHostName()
   }
 
   boost::replace_all(hostname, ".", "_");
+  hostname.resize(strlen(hostname.c_str()));
 
   return hostname;
 }