From: Remi Gacogne Date: Wed, 8 Apr 2020 08:25:10 +0000 (+0200) Subject: Make conversion to uint16_t explicit, as suggested by Otto X-Git-Tag: rec-4.5.0-alpha0~3^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F8993%2Fhead;p=thirdparty%2Fpdns.git Make conversion to uint16_t explicit, as suggested by Otto --- diff --git a/pdns/ednsoptions.cc b/pdns/ednsoptions.cc index b10e150aa0..ecfba3f867 100644 --- a/pdns/ednsoptions.cc +++ b/pdns/ednsoptions.cc @@ -30,11 +30,12 @@ bool getNextEDNSOption(const char* data, size_t dataLen, uint16_t& optionCode, u } size_t pos = 0; + const uint8_t* p = reinterpret_cast(data); - optionCode = (static_cast(data[pos]) * 256) + static_cast(data[pos + 1]); + optionCode = (static_cast(p[pos]) * 256) + p[pos + 1]; pos += EDNS_OPTION_CODE_SIZE; - optionLen = (static_cast(data[pos]) * 256) + static_cast(data[pos + 1]); + optionLen = (static_cast(p[pos]) * 256) + p[pos + 1]; pos += EDNS_OPTION_LENGTH_SIZE; return true; diff --git a/pdns/packetcache.hh b/pdns/packetcache.hh index bbb670df57..a8cf718888 100644 --- a/pdns/packetcache.hh +++ b/pdns/packetcache.hh @@ -59,7 +59,7 @@ public: /* already hashed above */ pos += 13; - const uint16_t rdLen = ((static_cast(packet.at(pos)) * 256) + static_cast(packet.at(pos + 1))); + const uint16_t rdLen = ((static_cast(packet.at(pos)) * 256) + static_cast(packet.at(pos + 1))); /* skip the rd length */ /* already hashed above */ pos += 2; @@ -116,7 +116,7 @@ public: static uint32_t hashHeaderAndQName(const std::string& packet, size_t& pos) { uint32_t currentHash = 0; - size_t packetSize = packet.size(); + const size_t packetSize = packet.size(); assert(packetSize >= sizeof(dnsheader)); currentHash = burtle(reinterpret_cast(&packet.at(2)), sizeof(dnsheader) - 2, currentHash); // rest of dnsheader, skip id pos = sizeof(dnsheader);