From: Pieter Lexis Date: Tue, 4 Sep 2018 14:05:38 +0000 (+0200) Subject: Ensure all the bits in a generated TSIG key are filled X-Git-Tag: auth-4.2.0-alpha1~17^2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1b1c0163ebae0571afa51fa96ef70e038186499a;p=thirdparty%2Fpdns.git Ensure all the bits in a generated TSIG key are filled --- diff --git a/pdns/tsigutils.cc b/pdns/tsigutils.cc index 20fb1c59ea..af67dac5ed 100644 --- a/pdns/tsigutils.cc +++ b/pdns/tsigutils.cc @@ -48,10 +48,10 @@ std::string makeTSIGKey(const DNSName& algorithm) { string tmpkey; tmpkey.resize(klen); - for (size_t i = 0; i < klen; i += sizeof(uint32_t)) { - unsigned int t = dns_random(std::numeric_limits::max()); - memcpy(&tmpkey.at(i), &t, sizeof(uint32_t)); - if (i + sizeof(uint32_t) > klen) { + for (size_t i = 0; i < klen; i += sizeof(unsigned int)) { + unsigned int t = dns_random(std::numeric_limits::max()); + memcpy(&tmpkey.at(i), &t, sizeof(unsigned int)); + if (i + sizeof(unsigned int) > klen) { size_t needed_bytes = klen - i; for (size_t j = 0; j < needed_bytes; j++) { uint8_t v = dns_random(0xff);