QHttp2ProtocolHandler: prevent truncation in arithmetic operations
On 64-bit systems, both the requests.size() and the activeStreams.size() were truncated to uint32_t values from int64_t ones. While extremely unlikely that either will contain more than 4Gi elements, avoid the truncation by verifying that the `max` amount of streams is larger than the activeStreams, and then using size_t for the range. Change-Id: I50644cb634bab0f020acf9aea1d03744b11dbe51 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Juha Vuolle <juha.vuolle@qt.io> (cherry picked from commit 22c99cf498103c86baa5a415ca34630396e5b6aa) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
d97be285dd
commit
f500429ace
@ -325,11 +325,11 @@ bool QHttp2ProtocolHandler::sendRequest()
|
|||||||
initReplyFromPushPromise(message, key);
|
initReplyFromPushPromise(message, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto streamsToUse = std::min<quint32>(maxConcurrentStreams > quint32(activeStreams.size())
|
Q_ASSERT(qint64(maxConcurrentStreams) >= activeStreams.size());
|
||||||
? maxConcurrentStreams - quint32(activeStreams.size()) : 0,
|
const size_t streamsToUse = std::min(maxConcurrentStreams - size_t(activeStreams.size()),
|
||||||
requests.size());
|
size_t(requests.size()));
|
||||||
auto it = requests.begin();
|
auto it = requests.begin();
|
||||||
for (quint32 i = 0; i < streamsToUse; ++i) {
|
for (size_t i = 0; i < streamsToUse; ++i) {
|
||||||
const qint32 newStreamID = createNewStream(*it);
|
const qint32 newStreamID = createNewStream(*it);
|
||||||
if (!newStreamID) {
|
if (!newStreamID) {
|
||||||
// TODO: actually we have to open a new connection.
|
// TODO: actually we have to open a new connection.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user