aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4executablecompilationunit.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2022-01-11 10:11:05 +0100
committerUlf Hermann <ulf.hermann@qt.io>2022-01-20 19:33:01 +0100
commited6b31389ac554287b4e00a6ad743e6ebf72160f (patch)
tree31eddc49096fc4c33a58a7755ec5d560c832ee61 /src/qml/jsruntime/qv4executablecompilationunit.cpp
parent3aad05bc09f40d81df7748cbc246974230a3ca17 (diff)
Further tighten checks around QML_COMPILE_HASH
Log the differing hashes in case of a mismatch. Pick-to: 6.2 6.3 Task-number: QTBUG-99608 Change-Id: Id85306d3cfdb08d235c8717b441105c5d0b68cf3 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4executablecompilationunit.cpp')
-rw-r--r--src/qml/jsruntime/qv4executablecompilationunit.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/qml/jsruntime/qv4executablecompilationunit.cpp b/src/qml/jsruntime/qv4executablecompilationunit.cpp
index cfded3f858..845f44b6f1 100644
--- a/src/qml/jsruntime/qv4executablecompilationunit.cpp
+++ b/src/qml/jsruntime/qv4executablecompilationunit.cpp
@@ -75,8 +75,8 @@
// what the hash version is.
__attribute__((section(".qml_compile_hash")))
# endif
-const char qml_compile_hash[48 + 1] = QML_COMPILE_HASH;
-static_assert(sizeof(QV4::CompiledData::Unit::libraryVersionHash) >= QML_COMPILE_HASH_LENGTH + 1,
+const char qml_compile_hash[QV4::CompiledData::QmlCompileHashSpace] = QML_COMPILE_HASH;
+static_assert(sizeof(QV4::CompiledData::Unit::libraryVersionHash) > QML_COMPILE_HASH_LENGTH,
"Compile hash length exceeds reserved size in data structure. Please adjust and bump the format version");
#else
# error "QML_COMPILE_HASH must be defined for the build of QtDeclarative to ensure version checking for cache files"
@@ -939,8 +939,14 @@ bool ExecutableCompilationUnit::verifyHeader(
}
#if defined(QML_COMPILE_HASH) && defined(QML_COMPILE_HASH_LENGTH) && QML_COMPILE_HASH_LENGTH > 0
- if (qstrcmp(qml_compile_hash, unit->libraryVersionHash) != 0) {
- *errorString = QStringLiteral("QML library version mismatch. Expected compile hash does not match");
+ if (qstrncmp(qml_compile_hash, unit->libraryVersionHash, QML_COMPILE_HASH_LENGTH) != 0) {
+ *errorString = QStringLiteral("QML compile hashes don't match. Found %1 expected %2")
+ .arg(QString::fromLatin1(
+ QByteArray(unit->libraryVersionHash, QML_COMPILE_HASH_LENGTH)
+ .toPercentEncoding()),
+ QString::fromLatin1(
+ QByteArray(qml_compile_hash, QML_COMPILE_HASH_LENGTH)
+ .toPercentEncoding()));
return false;
}
#else