fix: Prevent out-of-bounds access for Qt string when building TLS fingerprint

Only happens when using debug build of Qt lib because release Qt is optimized and doesn't check for bounds for the sake of efficiency.
This commit is contained in:
Nick Bolton 2025-11-10 13:32:52 +00:00
parent 477c7b07e5
commit 39382bfd8c

View file

@ -157,8 +157,9 @@ QString formatSSLFingerprintColumns(const QByteArray &fingerprint)
QString formattedString;
while (!hex.isEmpty()) {
formattedString.append(hex.first(kMaxColumns));
hex.remove(0, kMaxColumns);
const auto take = std::min<size_t>(kMaxColumns, hex.size());
formattedString.append(hex.first(take));
hex.remove(0, take);
if (formattedString.endsWith(':'))
formattedString.removeLast();
formattedString.append('\n');