Commit 30f26a2b authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

nghttpx: Explicitly cast to uint32_t for hash calculation

parent ca39c71a
......@@ -687,7 +687,9 @@ uint32_t compute_affinity_from_ip(const StringRef &ip) {
return util::hash32(ip);
}
return (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3];
return (static_cast<uint32_t>(buf[0]) << 24) |
(static_cast<uint32_t>(buf[1]) << 16) |
(static_cast<uint32_t>(buf[2]) << 8) | static_cast<uint32_t>(buf[3]);
}
} // namespace
......
......@@ -2854,8 +2854,10 @@ int compute_affinity_hash(std::vector<AffinityHash> &res, size_t idx,
}
for (int i = 0; i < 8; ++i) {
auto h = (buf[4 * i] << 24) | (buf[4 * i + 1] << 16) |
(buf[4 * i + 2] << 8) | buf[4 * i + 3];
auto h = (static_cast<uint32_t>(buf[4 * i]) << 24) |
(static_cast<uint32_t>(buf[4 * i + 1]) << 16) |
(static_cast<uint32_t>(buf[4 * i + 2]) << 8) |
static_cast<uint32_t>(buf[4 * i + 3]);
res.emplace_back(idx, h);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment