}
size_t pos = 0;
+ const uint8_t* p = reinterpret_cast<const uint8_t*>(data);
- optionCode = (static_cast<unsigned char>(data[pos]) * 256) + static_cast<unsigned char>(data[pos + 1]);
+ optionCode = (static_cast<uint16_t>(p[pos]) * 256) + p[pos + 1];
pos += EDNS_OPTION_CODE_SIZE;
- optionLen = (static_cast<unsigned char>(data[pos]) * 256) + static_cast<unsigned char>(data[pos + 1]);
+ optionLen = (static_cast<uint16_t>(p[pos]) * 256) + p[pos + 1];
pos += EDNS_OPTION_LENGTH_SIZE;
return true;
/* already hashed above */
pos += 13;
- const uint16_t rdLen = ((static_cast<unsigned char>(packet.at(pos)) * 256) + static_cast<unsigned char>(packet.at(pos + 1)));
+ const uint16_t rdLen = ((static_cast<uint16_t>(packet.at(pos)) * 256) + static_cast<uint16_t>(packet.at(pos + 1)));
/* skip the rd length */
/* already hashed above */
pos += 2;
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<const unsigned char*>(&packet.at(2)), sizeof(dnsheader) - 2, currentHash); // rest of dnsheader, skip id
pos = sizeof(dnsheader);