diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2021-07-04 23:44:01 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2021-07-27 13:23:20 +0200 |
commit | 3fa9c1948168b8eac29b8fb72345a718025a4213 (patch) | |
tree | 1e4ea574fc278488697274ed0d98892493141ca7 /src | |
parent | b26f39b946d448ea46ab797a1f3ad0b8e64be7ab (diff) |
QCryptographicHash: don't present the same data over and over again
Need to decrement 'remaining' (check), but also increment data (meep).
Testing is a bit complicated, as most algorithms are just too slow to
fit into the 5min QTestLib timeout. Picked the fast ones and Sha512
(which completes here in < 17s, with threads), at least.
Amends e12577b56396cca0df05f88f8787706a3a12c82d.
[ChangeLog][QtCore][QCryptographicHash] Fixed a bug where presenting
more than 4GiB in a single addData() call would calculate the wrong
result().
Change-Id: Ic72916ebc33ba087d58225af6d8240e46e41f434
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
(cherry picked from commit 35453446a511366e1250858b249e36c80b6ad044)
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/tools/qcryptographichash.cpp | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/src/corelib/tools/qcryptographichash.cpp b/src/corelib/tools/qcryptographichash.cpp index 47b72038eb..f6db6b976c 100644 --- a/src/corelib/tools/qcryptographichash.cpp +++ b/src/corelib/tools/qcryptographichash.cpp @@ -363,10 +363,8 @@ void QCryptographicHash::addData(const char *data, qsizetype length) // feed the data UINT_MAX bytes at a time, as some of the methods below // take a uint (of course, feeding more than 4G of data into the hashing // functions will be pretty slow anyway) - qsizetype remaining = length; - while (remaining) { + for (auto remaining = length; remaining; remaining -= length, data += length) { length = qMin(qsizetype(std::numeric_limits<uint>::max()), remaining); - remaining -= length; #else { #endif |