From 42e3f980ecbedb3ec0a65d71bba4da4d4d1a5ef2 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 11 Aug 2017 14:36:23 +0200 Subject: qmake: fix hypothetical raw data leaks relating to qt i/o classes technically, we should not rely on the i/o classes not storing the strings beyond the instantiated object's life time. Change-Id: I0990769b3cf86860184869036c096c531160e9be Reviewed-by: Joerg Bornemann (cherry picked from qtbase/702be65532263bd52ad0b67235c112083120699e) Reviewed-by: Tobias Hunger --- src/shared/proparser/qmakebuiltins.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/shared/proparser/qmakebuiltins.cpp b/src/shared/proparser/qmakebuiltins.cpp index 198a85c94c..102252fdaf 100644 --- a/src/shared/proparser/qmakebuiltins.cpp +++ b/src/shared/proparser/qmakebuiltins.cpp @@ -818,7 +818,8 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand( if (args.count() < 1 || args.count() > 2) { evalError(fL1S("cat(file, singleline=true) requires one or two arguments.")); } else { - const QString &file = args.at(0).toQString(m_tmp1); + QString fn = resolvePath(m_option->expandEnvVars(args.at(0).toQString(m_tmp1))); + fn.detach(); bool blob = false; bool lines = false; @@ -833,7 +834,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand( lines = true; } - QFile qfile(resolvePath(m_option->expandEnvVars(file))); + QFile qfile(fn); if (qfile.open(QIODevice::ReadOnly)) { QTextStream stream(&qfile); if (blob) { @@ -909,7 +910,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand( lines = true; } int exitCode; - QByteArray bytes = getCommandOutput(args.at(0).toQString(m_tmp2), &exitCode); + QByteArray bytes = getCommandOutput(args.at(0).toQString(), &exitCode); if (args.count() > 2 && !args.at(2).isEmpty()) { m_valuemapStack.top()[args.at(2).toKey()] = ProStringList(ProString(QString::number(exitCode))); @@ -1703,7 +1704,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional( #ifndef QT_BOOTSTRAPPED QProcess proc; proc.setProcessChannelMode(QProcess::ForwardedChannels); - runProcess(&proc, args.at(0).toQString(m_tmp2)); + runProcess(&proc, args.at(0).toQString()); return returnBool(proc.exitStatus() == QProcess::NormalExit && proc.exitCode() == 0); #else int ec = system((QLatin1String("cd ") @@ -1740,8 +1741,10 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional( return ReturnTrue; int slsh = file.lastIndexOf(QLatin1Char('/')); QString fn = file.mid(slsh+1); + fn.detach(); if (fn.contains(QLatin1Char('*')) || fn.contains(QLatin1Char('?'))) { QString dirstr = file.left(slsh+1); + dirstr.detach(); if (!QDir(dirstr).entryList(QStringList(fn)).isEmpty()) return ReturnTrue; } @@ -1754,7 +1757,8 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional( return ReturnFalse; } #ifdef PROEVALUATOR_FULL - const QString &fn = resolvePath(args.at(0).toQString(m_tmp1)); + QString fn = resolvePath(args.at(0).toQString(m_tmp1)); + fn.detach(); if (!QDir::current().mkpath(fn)) { evalError(fL1S("Cannot create directory %1.").arg(QDir::toNativeSeparators(fn))); return ReturnFalse; -- cgit v1.2.1