summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason McDonald <jason.mcdonald@nokia.com>2010-11-24 07:00:20 (GMT)
committerJason McDonald <jason.mcdonald@nokia.com>2010-11-24 07:00:20 (GMT)
commitfe8276e812c5fdc690715d7e36a6b6d70cba7d33 (patch)
treef899ea57702fdb78e2a57d4107d84651c65a3957
parentd0f74ae9712b2225c12c95891357c5f93c30996c (diff)
downloadQt-fe8276e812c5fdc690715d7e36a6b6d70cba7d33.zip
Qt-fe8276e812c5fdc690715d7e36a6b6d70cba7d33.tar.gz
Qt-fe8276e812c5fdc690715d7e36a6b6d70cba7d33.tar.bz2
Prevent compilers optimizing eval timebomb code out of existence.
The variable that holds the eval license key is a placeholder that is patched during package installation. Unfortunately, for a non-final package build, the placeholder is filled with nulls at compile-time and a clever compiler will optimize away most of the eval timebomb code due to a check in the eval code for the first character of the license key being null. This commit makes the variable that holds the license key volatile, to convince compilers that they cannot make assumptions about the contents of the variable when optimizing. Task-number: QT-3848 Acked-by: Thiago Macieira
-rwxr-xr-xconfigure2
-rw-r--r--src/corelib/kernel/qtcore_eval.cpp4
-rw-r--r--tools/configure/configureapp.cpp2
3 files changed, 4 insertions, 4 deletions
diff --git a/configure b/configure
index 5aab180..059aa1a 100755
--- a/configure
+++ b/configure
@@ -4520,7 +4520,7 @@ if [ -n "$EVALKEY" ]; then
rm -f "$outpath/src/corelib/global/qconfig_eval.cpp"
cat > "$outpath/src/corelib/global/qconfig_eval.cpp" <<EOF
/* Evaluation license key */
-static const char qt_eval_key_data [512 + 12] = "$EVALKEY";
+static const volatile char qt_eval_key_data [512 + 12] = "$EVALKEY";
EOF
chmod -w "$outpath/src/corelib/global/qconfig_eval.cpp"
fi
diff --git a/src/corelib/kernel/qtcore_eval.cpp b/src/corelib/kernel/qtcore_eval.cpp
index 78556c3..da76b74 100644
--- a/src/corelib/kernel/qtcore_eval.cpp
+++ b/src/corelib/kernel/qtcore_eval.cpp
@@ -90,14 +90,14 @@ static const char will_shutdown_now[] =
static int qt_eval_is_supported()
{
- const char *const license_key = qt_eval_key_data + 12;
+ const volatile char *const license_key = qt_eval_key_data + 12;
// fast fail
if (!qt_eval_key_data[0] || !*license_key)
return -1;
// is this an unsupported evaluation?
- const char* typecode = license_key;
+ const volatile char *typecode = license_key;
int field = 2;
for ( ; field && *typecode; ++typecode)
if (*typecode == '-')
diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp
index 3808c4e..5966fd2 100644
--- a/tools/configure/configureapp.cpp
+++ b/tools/configure/configureapp.cpp
@@ -3331,7 +3331,7 @@ void Configure::generateConfigfiles()
if (tmpFile3.open()) {
tmpStream.setDevice(&tmpFile3);
tmpStream << "/* Evaluation license key */" << endl
- << "static const char qt_eval_key_data [512 + 12] = \"qt_qevalkey=" << licenseInfo["LICENSEKEYEXT"] << "\";" << endl;
+ << "static const volatile char qt_eval_key_data [512 + 12] = \"qt_qevalkey=" << licenseInfo["LICENSEKEYEXT"] << "\";" << endl;
tmpStream.flush();
tmpFile3.flush();