From 39382bfd8c1f01e7aacb5d057b4b22f066832783 Mon Sep 17 00:00:00 2001 From: Nick Bolton Date: Mon, 10 Nov 2025 13:32:52 +0000 Subject: [PATCH] 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. --- src/lib/net/SecureUtils.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lib/net/SecureUtils.cpp b/src/lib/net/SecureUtils.cpp index af70df40e..8b5b5e9df 100644 --- a/src/lib/net/SecureUtils.cpp +++ b/src/lib/net/SecureUtils.cpp @@ -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(kMaxColumns, hex.size()); + formattedString.append(hex.first(take)); + hex.remove(0, take); if (formattedString.endsWith(':')) formattedString.removeLast(); formattedString.append('\n');